fix(pam): stop retrying rejected recording chunks - #392
Conversation
|
💬 Discussion in Slack: #pr-review-cli-392-fix-pam-stop-retrying-rejected-recording-chunks Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel. |
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 3 · PR risk: 0/10 |
Chunk reconciliation retried every failed upload on a five-minute tick with no give-up, so a chunk the platform can only ever reject was re-POSTed for the life of the gateway. One stuck queue produced 22,511 errors in three hours in production, and the burst also saturated the write rate limit. Treat 400, 403 and 404 as permanent and drop the chunk; keep 401, 429, 5xx and network failures retriable. A failed removal is reported rather than assumed, since such a chunk stays queued and keeps failing.
9a100f7 to
f00f424
Compare
Description 📣
Chunk reconciliation retried every failed upload on a 5-minute tick with no give-up, so a chunk the platform rejects for a reason that cannot change was re-POSTed for the life of the gateway. One stuck queue produced 22,511 errors in three hours in production, and the burst also saturated the write rate limit.
Fixes the gateway half of PAM-463; the platform half is in Infisical/infisical#8043. This is the only change that clears an already-stuck queue, so it needs to reach affected gateways for the error rate to drop.
Type ✨
Tests 🛠️
Four new tests drive
UploadChunkagainst a realhttptestserver withconfig.INFISICAL_URLoverridden, so the status code travels the genuine production path (resty response →NewAPIErrorWithResponse→fmt.Errorf("%w")→errors.As) rather than a synthetic error:400 Invalid upload tokendrops the chunk429and a real500both keep it queuedThe second commit adds
singleflightaround session credential fetches. Recording secrets are minted on a session's first fetch, and the cache check released its lock before the API call, so two connections on one session both fetched and both minted, leaving this gateway holding a token the platform had discarded. Covered by a test that fires 16 concurrent callers and asserts one fetch, run under-race.Also built the binary from this branch and ran it as a real gateway against a local platform: it enrolls, connects to the relay, heartbeats, and starts the session uploader with no errors.