Back off exponentially when the pylon orchestration SQLite is busy

02a0364b5587 · AtlantisPleb · · parent 5be79def3a08

Back off exponentially when the pylon orchestration SQLite is busy

Three or more pylon workers starting at the same moment can race on the
shared orchestration SQLite. withSqliteBusyRetry was doing 4 attempts with
25/50/75ms sleeps, which is not enough time for the writer to clear. It now
does 8 attempts with exponential backoff capped at 5s.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Deploy story

What this commit did to the running system — joined from the forge receipt chain, the part a commit page elsewhere cannot show.

Not deployed through the forge lane

No push, promotion, build, or deploy receipt references this commit (receipts are scanned over a bounded recent window). Changes shipped by full node replacement carry their proof in the release gate receipt instead.

Changed files

  • modified apps/pylon/src/orchestration/supervisor-state.ts

Diff

1 file changed, +6 -3

apps/pylon/src/orchestration/supervisor-state.ts modified +6 -3

@@ -61,13 +61,16 @@ const isSqliteBusy = (error: unknown): boolean =>

61 61
62 62
const withSqliteBusyRetry = <T>(fn: () => T): T => {
63 63
  let lastError: unknown
64
  for (let attempt = 0; attempt < 4; attempt += 1) {
64
  for (let attempt = 0; attempt < 8; attempt += 1) {
65 65
    try {
66 66
      return fn()
67 67
    } catch (error) {
68
      if (!isSqliteBusy(error) || attempt === 3) throw error
68
      if (!isSqliteBusy(error) || attempt === 7) throw error
69 69
      lastError = error
70
      sleepSync(25 * (attempt + 1))
70
      // SQLite contention is transient, but 3 or more workers can start at
71
      // the same moment, so the backoff grows exponentially rather than
72
      // racing on the same short windows.
73
      sleepSync(Math.min(5000, 50 * 2 ** attempt))
71 74
    }
72 75
  }
73 76
  throw lastError

This page updates live while a promote is in flight · changelog