service/database: use WAL mode + safe PRAGMA synchronous setting
Setting PRAGMA synchronous = 0 is really unsafe, and leads to database corruption (which I've personally experienced). This commit uses SQLite's Write-Ahead Log (WAL) [1] instead, together with synchronous = NORMAL. According to [1], this trades off performance for durability (i.e. it's possible that some transactions may not have committed if the power gets lost), but still guarantees that the database won't corrupt itself. Together, these changes should improve reliability whilst either improving or having no effect on performance. [1]: https://www.sqlite.org/wal.html
This commit is contained in:
parent
7b58c1596a
commit
9cc3382abe
|
@ -293,12 +293,9 @@ public class Database : Qlite.Database {
|
||||||
mam_catchup = new MamCatchupTable(this);
|
mam_catchup = new MamCatchupTable(this);
|
||||||
settings = new SettingsTable(this);
|
settings = new SettingsTable(this);
|
||||||
init({ account, jid, entity, content_item, message, message_correction, real_jid, file_transfer, conversation, avatar, entity_identity, entity_feature, roster, mam_catchup, settings });
|
init({ account, jid, entity, content_item, message, message_correction, real_jid, file_transfer, conversation, avatar, entity_identity, entity_feature, roster, mam_catchup, settings });
|
||||||
try {
|
exec("PRAGMA journal_mode = WAL");
|
||||||
exec("PRAGMA synchronous=0");
|
exec("PRAGMA synchronous = NORMAL");
|
||||||
} catch (Error e) { }
|
exec("PRAGMA secure_delete = ON");
|
||||||
try {
|
|
||||||
exec("PRAGMA secure_delete=1");
|
|
||||||
} catch (Error e) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void migrate(long oldVersion) {
|
public override void migrate(long oldVersion) {
|
||||||
|
|
Loading…
Reference in a new issue