Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a CoreData multithreading issue in LoggerStore.info() #293

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

ejensen
Copy link
Contributor

@ejensen ejensen commented Sep 19, 2024

LoggerStore.info() uses NSPersistentContainer.performBackgroundTask to construct the info. The background task constructs has its now NSManagedObjectContext that must be used throughout the task.

However getBlobsSize() was using a different backgroundContext to fetch the sum of the blob size. This mismatch of contexts causes a CoreData multithreading assertion to be triggered.

This PR addresses this issue by supplying the correct NSManagedObjectContext to use within getBlobsSize()

The store info is constructed using a background task. The background task constructs its own context that needs to be used throughout the task
@kean kean merged commit 2380f56 into kean:main Sep 19, 2024
8 of 9 checks passed
@kean
Copy link
Owner

kean commented Sep 19, 2024

Great catch, thank you!

@ejensen ejensen deleted the core-data-threading-issue branch October 9, 2024 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants