Skip to content

fix(audit): grow writeAuditEntry 412 backoff to 6 retries / ~3050 ms#282

Merged
kptdobe merged 2 commits into
mainfrom
cor-39-audit-retries-6
May 21, 2026
Merged

fix(audit): grow writeAuditEntry 412 backoff to 6 retries / ~3050 ms#282
kptdobe merged 2 commits into
mainfrom
cor-39-audit-retries-6

Conversation

@kptdobe

@kptdobe kptdobe commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

PR #277 widened the writeAuditEntry 412 backoff from linear (~500 ms) to exponential jitter (~750 ms worst-case) but kept the 4-retry cap. Six days after that deploy the PreconditionFailed rate is still sustained at ~5614/24h — the contention window is wider than the per-write latency, so every retry inside a short window observes the same losing-etag generation.

This change adds two more retry hops to the same jitter formula:

50, 100, 200, 400, 800, 1600 ms (~3050 ms total worst-case)

Reversible diagnostic step. If the rate does not converge to <250/24h after deploy, the next escalation is an append-only ledger layout (one S3 object per audit entry under the existing audit-dir prefix) which removes the read-modify-write race entirely. That follow-up is tracked separately.

What changed

  • src/storage/version/audit.jsattempt < 4attempt < 6, docstring + comment refreshed to call out the contention model and the planned next escalation.
  • test/storage/version/audit.test.js — bump the persists-all-attempts test from 5 → 7 attempts; expand the jitter-backoff lockdown to assert the new exponential ladder (upperBounds = [50, 100, 200, 400, 800, 1600]), a new floor check that delay[5] >= 800 ms proves the 6th retry reached the new ceiling, and adjust total-sleep bounds to ~3050 ms.

No production behaviour changes for the success path — only the failure tail (412 burst) now retries longer before logging.

Test plan

  • mocha test/storage/version/audit.test.js — 25/25 pass.
  • mocha test/storage/version/put.test.js — 64/64 pass (call-site untouched).
  • eslint src/storage/version/audit.js test/storage/version/audit.test.js — clean.
  • Post-deploy: run the Coralogix writeAuditEntry-failed query from COR-39 for 3 consecutive daily reviews. Target <250/24h.

Tracking

kptdobe and others added 2 commits May 19, 2026 12:28
The previous mitigation (PR #277) widened the backoff from linear (~500 ms)
to exponential jitter (~750 ms worst-case) but kept the 4-retry cap. Six days
after that deploy the writeAuditEntry PreconditionFailed rate is still
sustained at ~5614/24h on a hot audit ledger key, indicating that the
contention window is wider than the per-write latency: every retry inside a
short window observes the same losing-etag generation, so timing knobs alone
have not converged.

This change adds two more retry hops to the same exponential jitter formula,
so the worst-case sleep ladder per attempt is now:

  50, 100, 200, 400, 800, 1600 ms (~3050 ms total)

The intent is reversible diagnostic data: if the rate does not drop below
the <250/24h target after this, the next escalation is an append-only ledger
layout (one S3 object per audit entry under the existing audit dir prefix)
which eliminates the read-modify-write race entirely.

Tests updated to assert the new contract (7 total attempts, 6 retries, new
exponential ceiling) and an additional lockdown that delay[5] reaches the
new ~800 ms floor on the final hop.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
…udget

The audit retry bump (4 -> 6 with exponential jitter, PR #282) raised the
worst-case write-audit budget from ~750 ms to ~3050 ms.

"PUT with If-Match: returns 412 when ETag does not match and does not
retry" mocks every PutObjectCommand to 412 so the audit writer exhausts its
full retry budget. Two consequences after the bump:

- Total PutObjectCommand calls: 6 -> 8 (1 main PUT + 7 audit attempts =
  1 initial + 6 retries).
- Wall time exceeds mocha's 2000 ms default, causing a timeout failure.

Updated the count assertion and added `this.timeout(8000)` so the test
covers the new 6-retry path without flaking.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kptdobe
kptdobe merged commit bc49409 into main May 21, 2026
6 checks passed
@kptdobe
kptdobe deleted the cor-39-audit-retries-6 branch May 21, 2026 11:54
adobe-bot pushed a commit that referenced this pull request May 21, 2026
## [1.9.1](v1.9.0...v1.9.1) (2026-05-21)

### Bug Fixes

* **audit:** grow writeAuditEntry 412 backoff to 6 retries / ~3050 ms ([#282](#282)) ([bc49409](bc49409)), closes [#277](#277)
@adobe-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.9.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants