Closes#1821
Two caveats:
- I wouldn't merge this before #1761 since it fails constantly against
`main` code
- Not sure if this works as intended with multiple threads, but we don't
support that in `stress` yet anyway
Reviewed-by: Pekka Enberg <penberg@iki.fi>
Closes#1822
Add fault type that reopens the DB and reconnects the connections. It
purposefully does not call conn.close(), as the default behavior of that
method is to checkpoint the database.
This easily exposes multiple manifestations of DB/WAL corruption caused
by this issue: https://github.com/tursodatabase/limbo/issues/1725
in fact, in my testing, every run fails when this fault is enabled.
Hence I've added the --disable-reopen-database flag if you want to try
to find some other bugs.
Closes#1762
This PR makes limbo read the database header and schema via the regular
pager `read_page()` route, instead of always reading it from the
database file. This is very important for correctness as modifications
to page 1 (containing header and schema) may exist in WAL frames, not
just the main database file. Without this, practically any real use of
the database would very quickly corrupt the DB as limbo would read the
incorrect page count from the stale page 1 copy in the database file,
and e.g. allocate the same rootpage for multiple tables and so on.
This issue has been so far hidden due to lack of tests and the fact that
`Connection::close()` checkpoints the DB by default, which has delayed
discovering this incredibly basic issue since most manual testing has
happened via CLI, and if everything is always checkpointed, reopening
the DB doesn't cause any problems.
This closes#1725
See also: #1762 (commit from this PR is bundled into this branch as
well)
EDIT: Also closes#1818Closes#1761
Add fault type that reopens the DB and reconnects the connections.
It purposefully does not call conn.close(), as the default behavior
of that method is to checkpoint the database.
This easily exposes multiple manifestations of DB/WAL corruption caused by
this issue: https://github.com/tursodatabase/limbo/issues/1725
in fact, in my testing, every run fails when this fault is enabled. Hence I've
added the --disable-reopen-database flag if you want to try to find some other
bugs.
A simple change to implement the `Debug` trait for the `Connection`,
similar to how it is implemented for `Database`. This should help users
in their application code with wrapping the connection.
Closes#1798
We also want to just ignore this under Antithesis:
``´
limbo.DatabaseError: Failed to open database: LockingError("Failed locking file. File is locked by another process")
```