-
Notifications
You must be signed in to change notification settings - Fork 237
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
Support for NSSQLitePragmasOption generally, WAL specifically #212
Comments
Hi Patrick, whats the result of this? Did you manage to get it working by just applying the pragmas? |
@DanielBroad I completely missed your reply. I was not able to get WAL working with ECD. I have changes on a branch, but I had to put it on hold due to time constraints. |
Has anyone made any more progress on this? WAL journal mode seems to be a requirement for utilizing multiple persistent store coordinators, as described in this WWDC session (~27:50). I created a sample app that illustrates the issue, where parallel operations on multiple persistent store coordinators causes the error: |
@patrickhartling are the changes you were working on pushed to an accessible branch? |
@jeffdgr8 Not at the moment. I do still have the branch, but it is at least two years out of date. I'm under the gun with work stuff right now, and it may be a few days before I can get it current again. |
@patrickhartling ok, thank you. I would like to continue looking into this. Any code you have made progress on, even if outdated, would be helpful. |
I added code to handle @patrickhartling I tested the code with new model versions and found it working with the changes I tested, which included adding entities, adding attributes, and removing entities from the schema. What were the issues you were experiencing migrating between managed object model versions? Maybe the errors you were experiencing have since been resolved with updates to the library? I can create a pull request for my changes if they look good to merge or make changes if you have any feedback. |
There do seem to be issues still in my production app, using multiple persistent store coordinators. While the database locking errors are alleviated by the usage of the WAL journaling mode (I wasn't able to reproduce them in my sample app), they aren't completely eliminated. I'm still receiving the error: |
I was able to resolve the locked database error completely by specifying a |
@jeffdgr8 That looks very similar to what I had added. If you were able to get it working reliably, then you got farther than I did! |
@patrickhartling yes, very similar! Glad to know we were on the same page. If you're still able to make use of the change, you might try it again and see if it's working now for you. |
@jeffdgr8 I will carve out some time for that. I've been wanting to put WAL to use for a long time, and I' be thrilled if your changes work for our use case. |
@patrickhartling hi, is there a chances to have SQLitePragmas support merged in the near future? |
@AKoulabukhov Maybe. I didn't end up having time to try out the change myself back in May, but I can try again next week. I'll make a reminder for myself. |
Has anyone worked on adding support for
NSSQLitePragmasOption
, particularly so that write-ahead logging (WAL) can be enabled? I have tried but am having only limited success. It's not so hard to extend ECD to execute thePRAGMA
SQLite statements from the dictionary associated withNSSQLitePragmasOption
in the persistent store options. Migrating between managed object model versions is proving terribly difficult, however.The one (more or less) related Stack Overflow post I ran across has a down-voted answer that indirectly refers to an Apple Technical Q&A. That Q&A post doesn't strike me as being truly relevant, particularly because the approach of disabling WAL before migrating does not make any difference for me. As far as I can tell, Apple's Core Data code is fully WAL-aware as long as the right options are supplied consistently. The challenge lies in ensuring that ECD handles WAL correctly.
It seems very much like the
EncryptedStore
object has to be deallocated to prevent possible corruption of the-wal
file and/or the encrypted store by theEncryptedStore
object allocated for the newer version of the managed object model. That seems sensible to me, but there is an unexpected wrinkle. When I do ensure that theEncryptedStore
object is deallocated, the-wal
and-shm
files are removed. Is that a normal side effect forsqlite3_close()
? I'm still working my way through the sqlcipher source to understand what to expect.If I execute the same code using
NSSQLiteStoreType
instead ofEncryptedStoreType
, the-wal
and-shm
files remain on disk after I execute steps to remove the persistent store from its coordinator. Perhaps theNSIncrementalStore
subclass forNSSQLiteStoreType
cleans up after itself differently thanEncryptedStore
does?The text was updated successfully, but these errors were encountered: