EXTRA DURABLE build setting to improve robustness against corruption
brodycj opened this issue · 4 comments
As discussed in http://sqlite.1065341.n5.nabble.com/Is-WAL-mode-more-robust-against-corruption-td99624.html:
From https://www.sqlite.org/pragma.html#pragma_synchronous the default PRAGMA synchronous
setting is FULL
, wonder if it should be EXTRA
instead.
Also waiting for more feedback if anyone else on the sqlite-users mailing list can find any possible cause for database corruption in this project. A couple possible causes for corruption on iOS that were recently fixed:
UPDATE: it is desired to use compile-time option to enable this setting by default, details in comment below
ALSO WANTED: use recent SQLite version (3.22.0) to eliminate possibility of corruption due to outdated SQLite version
From https://www.sqlite.org/pragma.html#pragma_synchronous the default
PRAGMA synchronous
setting isFULL
, wonder if it should beEXTRA
instead.
Probably better to use SQLITE_DEFAULT_SYNCHRONOUS=3
setting ref:
- https://www.sqlite.org/compile.html#extra_durable
- https://www.sqlite.org/compile.html#default_synchronous
- https://www.sqlite.org/pragma.html#pragma_synchronous
NOTE that it looks like SQLITE_EXTRA_DURABLE
is no longer supported ref: https://www.sqlite.org/compile.html#extra_durable (TBD information in https://www.sqlite.org/pragma.html#pragma_synchronous seems to be in conflict)
ADDITIONAL EXPLANATION: As I said after the response I got to http://sqlite.1065341.n5.nabble.com/Is-WAL-mode-more-robust-against-corruption-td99624.html I would expect that a mobile app may be terminated at any time and would not expect advanced notification to be 100% reliable, especially in a hybrid mobile stack, and should be robust against crashes including possible OS crashes due to bugs, battery issues, etc. This is why I am thinking it would be safest to use the compile-time equivalent to PRAGMA synchronous=3 (EXTRA).
Done in cordova-sqlite-storage & cordova-sqlite-ext, still needed in other plugin versions.
Also related: storesafe/cordova-sqlite-storage-help#34
This setting is now enabled.
For the sake of clarity, the following build-time definition is used on all platforms: SQLITE_DEFAULT_SYNCHRONOUS=3
This is the equivalent to using the following PRAGMA setting: PRAGMA schema.synchronous = EXTRA