1
0
mirror of https://github.com/aziascreations/BakaShrot.git synced 2026-11-23 20:58:46 +01:00

Stopped writing once SQLite rolled a batch back

- SQLite may roll a whole transaction back by itself (a full disk, an
  I/O error, out of memory). The writes after it then ran outside any
  transaction, each committed alone, while the batch failed and every
  write was answered ServerError: a retried push stored twice
- Every Batch operation after is refused now (Error::RolledBack,
  Batch::is_rolled_back), the batch fails, nothing in it stored; the
  server's writer stops running the group there
- batch.rs nothing_runs_once_sqlite_rolled_back (a ROLLBACK standing in
  for SQLite's); docs (storage.md) and revamp.md (step 18)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 23:41:04 +01:00
parent 8ebac633d0
commit a6ade535d0
6 changed files with 113 additions and 2 deletions
+1 -1
View File
@@ -362,7 +362,7 @@ fn refusal(error: bakashrot_storage::Error) -> RequestRefused {
Error::UnknownName(_) => ErrorCode::UnknownName,
Error::TooBig(_) => ErrorCode::TooBig,
Error::Query(_) => ErrorCode::QueryFailed,
Error::Sqlite(_) | Error::Unusable(_) => {
Error::Sqlite(_) | Error::Unusable(_) | Error::RolledBack => {
warn!("the database: {error}");
return server_error("the database failed");
}
+5
View File
@@ -196,6 +196,11 @@ fn write(writer: &mut Writer, group: Vec<(Write, oneshot::Sender<Outcome>)>) {
let mut outcomes = Vec::with_capacity(group.len());
let committed = writer.batch(|batch| {
for (write, _) in &group {
// SQLite rolled the group back (a full disk...): the batch
// fails, every write in it is refused below, none stored.
if batch.is_rolled_back() {
break;
}
outcomes.push(write.run(batch).map_err(refusal));
}
Ok(())