Skip to content

fix(gateway): fix large audit snapshot memory - #52

Merged
EitanWong merged 1 commit into
mainfrom
fix/51-stream-gateway-snapshot
Sep 30, 2026
Merged

EitanWong merged 1 commit into
mainfrom
fix/51-stream-gateway-snapshot

Conversation

@EitanWong

Copy link
Copy Markdown
Owner

Closes #51

Hangzhou pilot state was 222 MB: ~163 MB audit, ~57 MB prior lease secrets. PR #50 prunes the expired lease secrets; this change preserves the full durable audit history but encodes its array one record at a time rather than running json.MarshalIndent over the entire state. Go json.Encoder.Encode buffers each value, so encoding the full snapshot at once would not solve the peak-allocation issue. All other fields retain their JSON schema; the file remains atomically replaced with mode 0600.

Verification: regression compares a 10k-event streamed file with standard JSON encoding, including notification secrets and permissions; TMPDIR=/tmp bash scripts/check.sh passes (all tests, coverage, vet, UX smoke 17/17).

This is a source fix only. Production requires separately authorized single-service deployment with backup, rollback, and RSS/state-size/restart trend checks; do not alter the Hangzhou instance from this PR.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 324d898e-8907-4f27-9f09-da12b60f6c81


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@EitanWong EitanWong changed the title fix(gateway): stream large audit during snapshot save fix(gateway): fix large audit snapshot memory Sep 30, 2026
@EitanWong
EitanWong merged commit 9af806f into main Sep 30, 2026
7 of 8 checks passed
@EitanWong
EitanWong deleted the fix/51-stream-gateway-snapshot branch September 30, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(gateway): stream large audit snapshots to bound serialization memory

1 participant