-
I was following the tutorial here: https://github.com/groue/GRDB.swift/blob/master/Documentation/SharingADatabase.md. I need to share my database because I want to access it in my app extension for push notifications. I was introduced with some concepts I never encountered before (NSFileCoordinator, coordinate method, etc). It looked pretty intense just to open a database connection. I created an App group and I read it directly from it with a I was wondering why the complex setup is needed. 2 problems are tackled in the tutorial though. In my main app I already used a So in short: I am using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hello @Jasperav, When sharing a database between several processes, putting the database in the WAL journaling mode can be useful. It reduces the odds that one process fails accessing the database because another process holds a lock on the database file. The WAL mode may also play some role in the prevention of the 0xdead10cc exception, but I'm not quite sure. Still, reducing the odds of errors is the reason why the WAL mode is recommended. The GRDB apis kind of conflate the mode of the database, and the DatabaseQueue and DatabasePool classes. But what really happens is that DatabaseQueue does not modify the journaling mode, while DatabasePool forces the WAL mode (except read-only). That's because DatabasePool needs the WAL mode in order to provide the concurrent database accesses it promises. You can put the database in the WAL mode with a DatabaseQueue, with the If you share the database between multiple processes, you may not follow the WAL mode advice (but raise the odds of errors). If you follow the WAL mode advice, you can still use a DatabaseQueue. That would be totally OK. But you'd lose the ability to perform parallel reads provided by DatabasePool. |
Beta Was this translation helpful? Give feedback.
Hello @Jasperav,
When sharing a database between several processes, putting the database in the WAL journaling mode can be useful. It reduces the odds that one process fails accessing the database because another process holds a lock on the database file. The WAL mode may also play some role in the prevention of the 0xdead10cc exception, but I'm not quite sure.
Still, reducing the odds of errors is the reason why the WAL mode is recommended.
The GRDB apis kind of conflate the mode of the database, and the DatabaseQueue and DatabasePool classes. But what really happens is that DatabaseQueue does not modify the journaling mode, while DatabasePool forces the WAL mode (except read-only). That…