Skip to content

Commit

Permalink
rgw/sfs: Add SQLite busy_error(ec) utility
Browse files Browse the repository at this point in the history
Return true if ec is an error signaling a busy database and the
transaction that failed is safe to retry.

Signed-off-by: Marcel Lauhoff <[email protected]>
  • Loading branch information
Marcel Lauhoff committed Oct 13, 2023
1 parent 3a2771d commit 6bf9ed3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/rgw/driver/sfs/sqlite/errors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,16 @@ bool critical_error(int ec) {
}
}

bool busy_error(int ec) {
switch (ec) {
case SQLITE_BUSY:
case SQLITE_BUSY_RECOVERY:
case SQLITE_BUSY_SNAPSHOT:
case SQLITE_LOCKED:
return true;
default:
return false;
}
}

} // namespace rgw::sal::sfs::sqlite
3 changes: 2 additions & 1 deletion src/rgw/driver/sfs/sqlite/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
namespace rgw::sal::sfs::sqlite {

bool critical_error(int ec);
bool busy_error(int ec);

}
} // namespace rgw::sal::sfs::sqlite

0 comments on commit 6bf9ed3

Please sign in to comment.