Skip to main content

with_busy_retry

Function with_busy_retry 

Source
pub fn with_busy_retry<F>(op: F) -> Result<(), AppError>
where F: Fn() -> Result<(), AppError>,
Expand description

Executes op up to MAX_SQLITE_BUSY_RETRIES times with exponential backoff whenever the operation fails with SQLITE_BUSY / SQLITE_LOCKED.

Delay schedule (base = SQLITE_BUSY_BASE_DELAY_MS):

  • attempt 1 → base ms
  • attempt 2 → base * 2 ms
  • attempt 3 → base * 4 ms
  • attempt 4 → base * 8 ms
  • attempt 5 → base * 16 ms

After all retries are exhausted the last SQLITE_BUSY error is converted to AppError::DbBusy so callers can route on exit-code 15.