SQLite: The WAL-Reset Bug(sqlite.org) |
SQLite: The WAL-Reset Bug(sqlite.org) |
You will have great difficulty hitting this problem, even if you deliberately try.
The only app I've ever known to hit this problem was Tailscale, and that was because they were running sqlite3_wal_checkpoint() four times per second on a separate connection in a separate thread, and then they would hit the problem on one or two of their many servers about once a month. We were never able to reproduce this problem ourselves, until after we introduced new debugging code to deliberately force the problem.
After the problem was fixed, we gave Tailscale a modified version of SQLite that invoked sqlite3_log() with a warning whenever circumstances were such that the bug would have occurred had we not already fixed it. It took them a couple of months before they finally observed that log message. I'm not sure why it took that long - maybe the fix changed the timing just enough that the race became tighter and less likely to occur.