Sqlite: report unknown commit outcome after WAL I/O error (VL-SQLITE-02)

- Add TransactionState::Unknown: a failed COMMIT whose outcome cannot be
  proven (WAL I/O error after the commit record may be durable) is never
  reported as RolledBack.
- Keep the transaction Active when SQLite leaves it open after the error;
  reject commit/rollback on an Unknown transaction with a clear error.
- Extend the fault guard with commit_applied_before_error to model a lost
  commit acknowledgement, and cover Unknown, Active-retry and
  rollback-journal RolledBack paths.
This commit is contained in:
faumaray committed 2026-12-03 18:17:17 +03:00
1 parent 0002e74a7d
commit 7eaa96f9da
4 files changed
+165 -11

No files matched your search

+7 -1
View File
@@ -182,7 +182,9 @@ namespace Void::Sqlite
/// RAII transaction retaining shared ConnectionState. Never marks Committed
/// before COMMIT succeeds; inspects sqlite3_get_autocommit on error and after
/// statements so an automatic rollback is reported as RolledBack.
/// statements so an automatic rollback is reported as RolledBack. A failed
/// COMMIT whose outcome cannot be proven (WAL I/O error) is reported as
/// Unknown, never as RolledBack.
class Transaction
{
public:
@@ -199,6 +201,10 @@ namespace Void::Sqlite
[[nodiscard]] TransactionState state() const noexcept;
[[nodiscard]] bool is_active() const noexcept;
/// Commits the transaction. On failure state() is Active (SQLite kept
/// the transaction open; retry or roll back), RolledBack (SQLite ended
/// it and it was not committed), or Unknown (SQLite ended it but a WAL
/// I/O error means the commit may have taken effect).
Result<void> commit();
[[nodiscard]] Result<void> rollback_checked();
void rollback() noexcept;