fix(pam): cap recording chunk size and batch live uploads#257
Conversation
Postgres-backed session recordings could exceed the API body limit on big sessions, and live sessions created one chunk per event. Cap chunks at 512KB for the Postgres backend and stop the upload loop from spinning at the live write edge.
|
💬 Discussion in Slack: #pr-review-cli-257-fix-pam-cap-recording-chunk-size-and-batch-live-uploads Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel. |
|
| Filename | Overview |
|---|---|
| packages/pam/session/chunk_uploader.go | Adds pamPostgresMaxPlaintextBytes (512 KB) cap constant for Postgres chunks; oversized-chunk warning in EncryptAndQueueChunk still compares against the S3 64 MB limit. |
| packages/pam/session/uploader.go | Adds hasMore return value to readFromOffset to distinguish backlog from live-edge; flushSession selects per-backend chunk cap and stops draining once at the live write edge. Logic is correct. |
Comments Outside Diff (1)
-
packages/pam/session/chunk_uploader.go, line 223-225 (link)Oversized-chunk warning doesn't reflect the Postgres-specific cap
The guard here compares against
pamRecordingMaxPlaintextBytes(64 MB) for all backends. For Postgres sessions,flushSessionnow caps atpamPostgresMaxPlaintextBytes(512 KB), so if that cap were ever bypassed this warning would be silent until the payload reached 128× the intended limit. Sincesecrets.StorageBackendis already fetched a few lines below, the check could usepamPostgresMaxPlaintextByteswhensecrets.StorageBackend == storageBackendPostgres, which would make on-call alerting actionable for the right threshold.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Reviews (1): Last reviewed commit: "fix(pam): cap recording chunk size and b..." | Re-trigger Greptile
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: 1 · PR risk: 0/10 |
Description 📣
Postgres session recordings could get too big to upload once a session ran a while, and long sessions also piled up thousands of tiny chunks. This caps the chunk size and batches uploads so neither happens.
Type ✨
Tests 🛠️
Ran a gateway recording to Postgres locally: a big backlog now splits into capped chunks that upload fine, and a continuous session that used to make ~50 chunks/sec batches down to a couple.