xaya / libxayagame

MIT License
21 stars 19 forks source link

Explicitly truncate SQLite WAL file #123

Closed domob1812 closed 2 years ago

domob1812 commented 2 years ago

Especially when syncing or running a long time, the WAL file for an SQLite-based GSP might grow very large with database updates, even if in theory old state is already pruned (but still kept in the WAL).

This introduces a new optional flag, --xaya_sqlite_wal_truncate_ms, which can be used to force a full checkpointing and WAL-truncation in regular intervals.

Whenever a write is committed and the last checkpointing is longer ago than the chosen interval, the database will wait (still holding the Game lock) for any read snapshots to be finished and then request a full WAL checkpoint and truncating of the WAL file.