Repository navigation
chore(jobsdb): disable no results cache state filter optimization - #6964
Merged
Merged
Conversation
atzoum
force-pushed
the
chore.jobsdbStateOptimization
branch
from
May 16, 2026 11:55
d957f12 to
6b97284
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6964 +/- ##
=======================================
Coverage 80.08% 80.09%
=======================================
Files 565 565
Lines 63807 63811 +4
=======================================
+ Hits 51102 51107 +5
- Misses 9661 9665 +4
+ Partials 3044 3039 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
atzoum
marked this pull request as ready for review
May 18, 2026 06:15
atzoum
force-pushed
the
chore.jobsdbStateOptimization
branch
2 times, most recently
from
May 19, 2026 11:45
04a9a20 to
7b84767
Compare
ktgowtham
approved these changes
May 20, 2026
atzoum
force-pushed
the
chore.jobsdbStateOptimization
branch
2 times, most recently
from
May 21, 2026 07:07
7335bd7 to
8216db1
Compare
mihir20
reviewed
May 22, 2026
| resultsetStates := map[string]struct{}{} | ||
| for rows.Next() { | ||
| var payloadSize int64 | ||
| var rowPayloadSize int64 |
Contributor
There was a problem hiding this comment.
rowPayloadSize is not used, we do not need to read this
Contributor
Author
There was a problem hiding this comment.
We need to scan as it is part of the resultset. But since we don't use it we can declare it before the for loop. 👍
atzoum
force-pushed
the
chore.jobsdbStateOptimization
branch
2 times, most recently
from
May 22, 2026 18:42
b97d3a8 to
b31ff7a
Compare
…urable 🔒 Scanned for secrets using gitleaks 8.30.1
🔒 Scanned for secrets using gitleaks 8.30.1
🔒 Scanned for secrets using gitleaks 8.30.1
🔒 Scanned for secrets using gitleaks 8.30.1
atzoum
force-pushed
the
chore.jobsdbStateOptimization
branch
from
May 25, 2026 06:02
b31ff7a to
aee2f9e
Compare
mihir20
approved these changes
May 25, 2026
This was referenced May 25, 2026
Merged
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔒 Scanned for secrets using gitleaks 8.30.1
Description
Makes the per-state
noResultsCacheoptimization injobsdbconfigurable, and disables it by default.The optimization has two parts in
getJobsDS:stateFiltersare narrowed against the cache before querying, skipping states the cache reported as empty for the current(ds, partitions, workspace, customVals, params)key.Both are now gated behind a single reloadable flag
noResultsCacheStateOptimization:JobsDB.<tablePrefix>.noResultsCacheStateOptimizationJobsDB.noResultsCacheStateOptimizationDefault is
false(optimization disabled).Also fixes a variable-shadowing bug in
getJobsDSwhere the outerpayloadSizewas never updated due to an inner shadow, making the post-looppayloadSize >= PayloadSizeLimitcheck dead code. As a result,LimitsReachedwas wrongly reported asfalsewhen the payload limit was reached at the boundary (exact total) or when a single oversize job exhausted the budget alone. This is one of the concrete mechanisms that can poison thenoResultsCache— see the reasoning below.Reasoning
We suspect the per-state optimization is the root cause of
noResultsCachebeing populated with stale entries, which in turn leads to out-of-order processing: a state that actually has jobs is wrongly cached as empty, so subsequent reads skip those jobs from one dataset and process later jobs from another dataset first.The write-side commit predicate
(!ok && !limitsReached)assumes that when a state is missing from the result set and limits were not reached, we have exhaustively scanned the dataset for that state. This invariant can be broken by silent row-dropping filters that are not part of the cache key, or incorrect calculation of when limits are reached, and the resulting cache entry then poisons later reads.The
payloadSizeshadowing bug fixed in this PR is a concrete instance of the second class: at the payload-budget boundarylimitsReachedwas wrongly returned asfalse, so a state missing from the result set (e.g. because the budget was exhausted before any state-X row appeared) would satisfy(!ok && !limitsReached)and get committed to the cache as "no jobs for this state" — a stale entry that subsequent reads would honour, skipping real jobs and triggering out-of-order processing.Disabling the per-state optimization by default keeps only the coarser
len(jobList) == 0commit path, which can only record "no rows at all" results and is therefore not vulnerable to per-state misattribution.The optimization can be re-enabled per-deployment via the reloadable flag while we investigate and harden the invariants.
Linear Ticket
resolves PIPE-2994
Security