Skip to content
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

[bug/sqlite] sqlite.db-wal file grows indefinitely without flushing to sqlite.db #2808

Closed
tsmethurst opened this issue Apr 4, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@tsmethurst
Copy link
Contributor

Someone's reported this in the Matrix already too, but didn't open an issue for it yet. Opening it now since I can see the problem on my server as well:

-rw-r--r--    1 gotosocial gotosocial 7.1G Apr  3 00:01 sqlite.db
-rw-r--r--    1 gotosocial gotosocial 3.4M Apr  4 16:05 sqlite.db-shm
-rw-r--r--    1 gotosocial gotosocial 1.7G Apr  4 16:05 sqlite.db-wal

^^ Here there's a db size of 7.1G, which is fine for an old and widely federating instance, but a wal file of 1.7G, which is much, much larger than it ought to be. This won't cause any immediate problems on this particular server, but it is likely to cause slowdown over time since reading from the wal file is less optimized than reading from the db itself.

The SQLite docs contain some details on why this situation might occur: https://www.sqlite.org/wal.html#avoiding_excessively_large_wal_files

The one that jumps out at me is checkpoint starvation, particularly:

if a database has many concurrent overlapping readers and there is always at least one active reader, then no checkpoints will be able to complete and hence the WAL file will grow without bound.

We should see if we can figure out why this is happening; are we leaving readers open maybe? Or is there some change in the latest version of SQLite that we're using which disables the automatic checkpoint mechanism, or leaves too many readers open, or something?

We could also try enabling manual periodic checkpointing (once per 30 minutes or so), and see if this helps, though I feel like that might just mask some other underlying problem.

@tsmethurst tsmethurst added the bug Something isn't working label Apr 4, 2024
@tsmethurst
Copy link
Contributor Author

This looks very much like this: https://gitlab.com/cznic/sqlite/-/issues/179

@tsmethurst
Copy link
Contributor Author

Closed by #2811 (for now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant