Skip to content

fix: continuous backend config cache cause postgres disk bloat - #6983

Merged
atzoum merged 1 commit into
release/1.75.xfrom
harness/INF-2192-fix-skip-identical-config-cache-rew-1fbw
May 20, 2026
Merged

atzoum merged 1 commit into
release/1.75.xfrom
harness/INF-2192-fix-skip-identical-config-cache-rew-1fbw

Conversation

@rudder-devbox

@rudder-devbox rudder-devbox Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

The backend config cache persists the workspace config to postgres on every config update. On every update the row was rewritten regardless of whether the config value had actually changed or not. In postgres an UPDATE always writes a new tuple version — even when the new values equal the old ones — leaving the previous one dead; and since the large config value lives in TOAST, each rewrite churns the TOAST table too.

This becomes pathological when:

  • There are a lot of continuous configuration changes: every change is another full-row rewrite.
  • Multiple pods try to cache the same config: each pod independently writes the same config to the same row, so a single logical change becomes one write per pod, most of them re-writing a value identical to what another pod just stored.

Dead tuples accumulated faster than autovacuum reclaimed them, steadily bloating postgres disk usage.

Changes

  • Conditional upsert via content hash — a new config_hash column stores a SHA-256 hex digest of the marshalled config. The upsert now carries WHERE config_cache.config_hash IS DISTINCT FROM excluded.config_hash, so when the stored config is already identical the row is not rewritten and updated_at is not bumped. This de-duplicates both no-op updates and redundant cross-pod writes.
  • Skip redundant work — set does a cheap SELECT config_hash first and returns early on a match, so a pod that finds the config already cached skips encrypting and transferring the large config blob entirely.
  • Debounce writes — a burst of config updates is coalesced into a single write per pod, controlled by BackendConfig.dbCacheWriteDebounce (default 10s).
  • Aggressive TOAST autovacuum — the migration tunes config_cache so dead tuples from any remaining rewrites are reclaimed promptly (toast.autovacuum_vacuum_scale_factor = 0, toast.autovacuum_vacuum_threshold = 1).

Linear Ticket

resolves PIPE-3018

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@atzoum
atzoum force-pushed the harness/INF-2192-fix-skip-identical-config-cache-rew-1fbw branch from d1f6c2c to 4c0aeaf Compare May 20, 2026 11:22
🔒 Scanned for secrets using gitleaks 8.30.1
@atzoum
atzoum force-pushed the harness/INF-2192-fix-skip-identical-config-cache-rew-1fbw branch from 4c0aeaf to d84d304 Compare May 20, 2026 11:50
@atzoum
atzoum changed the base branch from master to release/1.75.x May 20, 2026 11:50
@atzoum atzoum changed the title fix: skip identical config_cache rewrites and tune toast autovacuum fix: continuous backend config cache cause postgres disk bloat May 20, 2026
@atzoum
atzoum marked this pull request as ready for review May 20, 2026 12:01
@atzoum
atzoum merged commit 398f902 into release/1.75.x May 20, 2026
77 checks passed
@atzoum
atzoum deleted the harness/INF-2192-fix-skip-identical-config-cache-rew-1fbw branch May 20, 2026 12:20
@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/1.75.x@b211809). Learn more about missing BASE report.

Files with missing lines Patch % Lines
backend-config/internal/cache/cache.go 95.12% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##             release/1.75.x    #6983   +/-   ##
=================================================
  Coverage                  ?   80.04%           
=================================================
  Files                     ?      565           
  Lines                     ?    63748           
  Branches                  ?        0           
=================================================
  Hits                      ?    51029           
  Misses                    ?     9695           
  Partials                  ?     3024           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

atzoum pushed a commit that referenced this pull request May 20, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.75.3](v1.75.2...v1.75.3)
(2026-05-20)


### Bug Fixes

* continuous backend config cache cause postgres disk bloat
([#6983](#6983))
([398f902](398f902))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
atzoum added a commit that referenced this pull request May 20, 2026
# Description

Syncing patch release v1.75.3 to main branch

**↓↓ Please review and edit commit overrides before merging ↓↓**

BEGIN_COMMIT_OVERRIDE
fix: continuous backend config cache cause postgres disk bloat (#6983)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Akash Chetty <[email protected]>
Co-authored-by: Akash <[email protected]>
Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
Co-authored-by: rudder-harness[bot] <278693763+rudder-harness[bot]@users.noreply.github.com>
Co-authored-by: Aris Tzoumas <[email protected]>
This was referenced May 25, 2026
mihir20 pushed a commit that referenced this pull request May 25, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.76.0-rc.1](v1.75.0...v1.76.0-rc.1)
(2026-05-25)


### Features

* per-workspace PyT routing + cold-start handling
([#6978](#6978))
([d81e175](d81e175))
* periodic cleanup of rsources shared db tables
([#6945](#6945))
([ed0dfe7](ed0dfe7))


### Bug Fixes

* **batchrouter:** preserve prior LastJobStatus error on drain
([#6958](#6958))
([af31e62](af31e62))
* **batchrouter:** preserve prior LastJobStatus error on drain
([#6958](#6958))
([193f797](193f797))
* clickhouse quarter partition type
([#6965](#6965))
([af31e62](af31e62))
* continuous backend config cache cause postgres disk bloat
([#6983](#6983))
([f45aa06](f45aa06))
* ignore failed messages when source job run id exists
([#6981](#6981))
([045fdc0](045fdc0))
* server getting stuck during startup while initializing rsources
([#6943](#6943))
([62791fa](62791fa))
* snowpipe streaming bulk status offset
([#6966](#6966))
([af31e62](af31e62))


### Miscellaneous

* **ci:** workflow cleanup (SEC-284)
([#6949](#6949))
([516ba5b](516ba5b))
* **deps:** bump actions/upload-artifact from 7.0.0 to 7.0.1
([#6892](#6892))
([866f04d](866f04d))
* **deps:** bump aws-actions/amazon-ecr-login from 2.0.1 to 2.1.4
([#6956](#6956))
([89f1168](89f1168))
* **deps:** bump docker/login-action from 4.0.0 to 4.1.0
([#6881](#6881))
([5bca875](5bca875))
* **deps:** bump rudderlabs/build-scan-push-action from 1.8.2 to 2.2.0
([#6955](#6955))
([78cc895](78cc895))
* **deps:** bump step-security/harden-runner from 2.16.0 to 2.19.1
([#6957](#6957))
([cc5b578](cc5b578))
* **jobsdb:** disable no results cache state filter optimization
([#6964](#6964))
([c20dad2](c20dad2))
* **jobsdb:** release dsList read lock early during store
([#6963](#6963))
([a172404](a172404))
* pyt contracts for ipc and multi threading
([#6942](#6942))
([d570865](d570865))
* remove unused sed deletion method from GZIPLocalFileHandler
([#6974](#6974))
([d788760](d788760))
* replace deprecated WithCredentialsJSON with WithAuthCredentialsJSON
([#6986](#6986))
([8395174](8395174))
* sync release v1.75.0 to main branch
([#6954](#6954))
([f16fe93](f16fe93))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
mihir20 pushed a commit that referenced this pull request May 26, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.76.0](v1.75.0...v1.76.0)
(2026-05-25)


### Features

* per-workspace PyT routing + cold-start handling
([#6978](#6978))
([d81e175](d81e175))
* periodic cleanup of rsources shared db tables
([#6945](#6945))
([ed0dfe7](ed0dfe7))


### Bug Fixes

* **batchrouter:** preserve prior LastJobStatus error on drain
([#6958](#6958))
([af31e62](af31e62))
* **batchrouter:** preserve prior LastJobStatus error on drain
([#6958](#6958))
([193f797](193f797))
* clickhouse quarter partition type
([#6965](#6965))
([af31e62](af31e62))
* continuous backend config cache cause postgres disk bloat
([#6983](#6983))
([f45aa06](f45aa06))
* ignore failed messages when source job run id exists
([#6981](#6981))
([045fdc0](045fdc0))
* server getting stuck during startup while initializing rsources
([#6943](#6943))
([62791fa](62791fa))
* snowpipe streaming bulk status offset
([#6966](#6966))
([af31e62](af31e62))


### Miscellaneous

* **ci:** workflow cleanup (SEC-284)
([#6949](#6949))
([516ba5b](516ba5b))
* **deps:** bump actions/upload-artifact from 7.0.0 to 7.0.1
([#6892](#6892))
([866f04d](866f04d))
* **deps:** bump aws-actions/amazon-ecr-login from 2.0.1 to 2.1.4
([#6956](#6956))
([89f1168](89f1168))
* **deps:** bump docker/login-action from 4.0.0 to 4.1.0
([#6881](#6881))
([5bca875](5bca875))
* **deps:** bump rudderlabs/build-scan-push-action from 1.8.2 to 2.2.0
([#6955](#6955))
([78cc895](78cc895))
* **deps:** bump step-security/harden-runner from 2.16.0 to 2.19.1
([#6957](#6957))
([cc5b578](cc5b578))
* **jobsdb:** disable no results cache state filter optimization
([#6964](#6964))
([c20dad2](c20dad2))
* **jobsdb:** release dsList read lock early during store
([#6963](#6963))
([a172404](a172404))
* pyt contracts for ipc and multi threading
([#6942](#6942))
([d570865](d570865))
* remove unused sed deletion method from GZIPLocalFileHandler
([#6974](#6974))
([d788760](d788760))
* replace deprecated WithCredentialsJSON with WithAuthCredentialsJSON
([#6986](#6986))
([8395174](8395174))
* sync release v1.75.0 to main branch
([#6954](#6954))
([f16fe93](f16fe93))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
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.

3 participants