Skip to content

chore(jobsdb): multi-consumer compaction - #7096

Merged
atzoum merged 1 commit into
masterfrom
feat.mcJobsDB5
Jun 26, 2026
Merged

atzoum merged 1 commit into
masterfrom
feat.mcJobsDB5

Conversation

@atzoum

@atzoum atzoum commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

Updates the dataset compaction paths for supporting the multi-consumer scenarios.

Consumer trimming: when carrying a job forward into the destination dataset, already-terminal consumers are stripped from its consumers array and only the surviving (still-pending) consumers' status rows are copied.

Status-table cleanup amplification: the periodic cleanup (cleanupStatusTables) triggers on a statuses-per-job ratio and a table-size threshold that assume one status row per job at steady state. For multi-consumer handles the healthy baseline is one row per (job, consumer), so both thresholds are scaled by the dataset's registry cardinality. A skipMultiConsumerStatusCompaction config key (default true for multi-consumer JobsDBs) allows for status compaction to be skipped entirely. Dataset-level compaction (move + drop) is unaffected.

Linear Ticket

resolves PIPE-3052

Security

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

This is part 1 of 5 in a stack made with GitButler:

@atzoum
atzoum marked this pull request as draft June 16, 2026 12:23
@atzoum
atzoum force-pushed the feat.mcJobsDB5 branch 2 times, most recently from 8dac98c to 57c415b Compare June 16, 2026 12:40
@atzoum atzoum changed the title chore(jobsdb): multiconsumer compaction chore(jobsdb): multi-consumer compaction Jun 16, 2026
@atzoum
atzoum force-pushed the feat.mcJobsDB5 branch 3 times, most recently from 65bbc12 to 0211c5d Compare June 17, 2026 07:37
@atzoum
atzoum changed the base branch from feat.mcJobsDBDDL2 to feat.mcJobsDB4 June 17, 2026 07:50
@codecov

codecov Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.58011% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.52%. Comparing base (9eff2e9) to head (8436b5f).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
jobsdb/jobsdb_multiconsumer.go 71.42% 3 Missing and 3 partials ⚠️
jobsdb/jobsdb_compaction.go 98.71% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #7096    +/-   ##
========================================
  Coverage   79.52%   79.52%            
========================================
  Files         584      584            
  Lines       65469    65620   +151     
========================================
+ Hits        52061    52183   +122     
- Misses      10298    10335    +37     
+ Partials     3110     3102     -8     

☔ View full report in Codecov by Harness.
📢 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.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat.mcJobsDB5

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 and usage tips.

@atzoum
atzoum force-pushed the feat.mcJobsDB5 branch 2 times, most recently from a8e1b4c to d07625b Compare June 19, 2026 09:56
Base automatically changed from feat.mcJobsDB4 to master June 24, 2026 08:30
threshold := jd.conf.compaction.vacuumFullStatusTableThreshold.Load()
for _, ds := range dsList {
if tableSizes[ds.JobStatusTable] > jd.conf.compaction.vacuumFullStatusTableThreshold.Load() {
scaledThreshold := threshold * max(dsConsumerCounts[ds.Index], 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth mentioning that ConsumerCounts is the total unique number of the consumers across all the jobs, as some jobs might have a different number of consumers than others?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, job status compaction is not efficient now for multi-consumer jobsdbs, but thankfully it is not needed for any of our current use cases

}
return statuses/jobs > jd.conf.compaction.jobStatusCompactionThres.Load()
// For multi-consumer datasets, one status row per (job, consumer) is the healthy baseline,
// so scale the denominator by the consumer count to preserve threshold semantics.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@atzoum
atzoum merged commit 57f1ef5 into master Jun 26, 2026
77 checks passed
@atzoum
atzoum deleted the feat.mcJobsDB5 branch June 26, 2026 06:09
atzoum added a commit that referenced this pull request Jun 26, 2026
# Description

Adds `GetDistinctConsumers` to the `JobsDB` interface, so we can
efficiently enumerate consumers and ping the relevant workers per
consumer.

It reuses the existing `distinctValuesCache` machinery (already used by
`GetDistinctParameterValues`), reading from the per-DS consumers
registry tables materialized at Store time.

## Linear Ticket

resolves PIPE-3124

## Security

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

<!-- GitButler Footer Boundary Top -->
---
This is **part 2 of 5 in a stack** made with GitButler:
- <kbd>&nbsp;5&nbsp;</kbd> #7122 
- <kbd>&nbsp;4&nbsp;</kbd> #7121 
- <kbd>&nbsp;3&nbsp;</kbd> #7098 
- <kbd>&nbsp;2&nbsp;</kbd> #7097 👈 
- <kbd>&nbsp;1&nbsp;</kbd> #7096 
<!-- GitButler Footer Boundary Bottom -->
atzoum added a commit that referenced this pull request Jun 29, 2026
# Description

Adds `GetPendingConsumerJobs`, a partition-migration-specific method to
fetch pending jobs while excluding their latest status(es).

- For a multi-consumer jobsdb, each returned job carries only the list
of consumers still pending.
- Reuses all the existing jobsdb optimizations (dataset iteration,
noResultsCache, limits, MoreToken, retry-on-compaction).
- Partition migration now uses this method and also communicates the
`consumers` field node-to-node (new `repeated string consumers = 12` on
the cluster `Job` proto message).

## Linear Ticket

resolves PIPE-3053

## Security

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

<!-- GitButler Footer Boundary Top -->
---
This is **part 3 of 5 in a stack** made with GitButler:
- <kbd>&nbsp;5&nbsp;</kbd> #7122 
- <kbd>&nbsp;4&nbsp;</kbd> #7121 
- <kbd>&nbsp;3&nbsp;</kbd> #7098 👈 
- <kbd>&nbsp;2&nbsp;</kbd> #7097 
- <kbd>&nbsp;1&nbsp;</kbd> #7096 
<!-- GitButler Footer Boundary Bottom -->
atzoum added a commit that referenced this pull request Jun 29, 2026
# Description

Consumer-aware pending events on multi-consumer handles, where a
consumer is a destination ID.

- **`pendingEventsJobsDB`**: new `WithConsumerAsDestinationID()` option.
In consumer mode the destination ID comes from `job.Consumers` (store)
and `status.Consumer` (update) instead of
`parameters->>'destination_id'`, so a job pending for N consumers emits
N pending events and a per-consumer terminal status decrements exactly
that destination. Default behaviour is unchanged.
- **`GetPileUpCounts`**: for multi-consumer handles, defaults to
per-consumer counting — fans out over `unnest(j.consumers)` and reports
the `consumer` as `destination_id`. No payload fan-out; `increaseFunc`
signature unchanged.
- **`Store`**: single-consumer handles now always persist `consumers =
{''}` regardless of `job.Consumers`. A shared `defaultConsumers`
sentinel avoids a per-job slice allocation on the store path.

## Linear Ticket

resolves PIPE-3154

## Security

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

<!-- GitButler Footer Boundary Top -->
---
This is **part 4 of 5 in a stack** made with GitButler:
- <kbd>&nbsp;5&nbsp;</kbd> #7122 
- <kbd>&nbsp;4&nbsp;</kbd> #7121 👈 
- <kbd>&nbsp;3&nbsp;</kbd> #7098 
- <kbd>&nbsp;2&nbsp;</kbd> #7097 
- <kbd>&nbsp;1&nbsp;</kbd> #7096 
<!-- GitButler Footer Boundary Bottom -->
atzoum added a commit that referenced this pull request Jun 29, 2026
# Description

Removes five jobsdb config flags that have settled on a single value,
collapsing each gated code path to its always-taken branch:

- `noResultsCacheStateOptimization` (always false) — drop the per-state
cache optimization
- `getJobsUseLateralJoin` (always true) — always use the LATERAL join in
`getJobsDS`
- `nonBlockingCompaction` (always true) — remove the legacy
`doCompaction` body (`doCompactDS` becomes `doCompaction`)
- `compactionDeferStatusLock` (always true) — deferred two-phase status
copy is now the only path
- `nonBlockingCompletedDSDrop` — removed (only lived in the deleted
legacy path)
- `holdDSListLockDuringStore` (always false) — remove the option to hold
dsListLock while storing

Also drops the now-orphaned helpers (`compactJobsInTx`,
`computeNewIdxForIntraNodeCompaction`, `postCompactionHandleDS`) and
updates/removes the tests that exercised the removed branches.

## Security

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

<!-- GitButler Footer Boundary Top -->
---
This is **part 5 of 5 in a stack** made with GitButler:
- <kbd>&nbsp;5&nbsp;</kbd> #7122 👈 
- <kbd>&nbsp;4&nbsp;</kbd> #7121 
- <kbd>&nbsp;3&nbsp;</kbd> #7098 
- <kbd>&nbsp;2&nbsp;</kbd> #7097 
- <kbd>&nbsp;1&nbsp;</kbd> #7096 
<!-- GitButler Footer Boundary Bottom -->
This was referenced Jun 29, 2026
atzoum pushed a commit that referenced this pull request Jun 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.79.0-rc.1](v1.78.0...v1.79.0-rc.1)
(2026-06-29)


### Features

* support compressing payloads in reporting client
([#7124](#7124))
([365b530](365b530))
* support deltalake azure hierarchical namespace folders
([#7089](#7089))
([61b41e4](61b41e4))


### Bug Fixes

* panic in user transformer client due to timeout doesn't get recorded
by alerts
([#7116](#7116))
([61b41e4](61b41e4))
* partition migration restarts server on slow in-progress wait
([#7129](#7129))
([d63d597](d63d597))


### Miscellaneous

* **jobsdb:** capturing multi-consumer pending events
([#7121](#7121))
([dc382f7](dc382f7))
* **jobsdb:** cleanup legacy configuration flags
([#7122](#7122))
([58778d5](58778d5))
* **jobsdb:** multi-consumer compaction
([#7096](#7096))
([57f1ef5](57f1ef5))
* **jobsdb:** multi-consumer get and noresults cache handling
([#7095](#7095))
([9d5c58a](9d5c58a))
* **jobsdb:** multi-consumer get distinct consumers
([#7097](#7097))
([f68a56d](f68a56d))
* **jobsdb:** multi-consumer partition migration
([#7098](#7098))
([9cda68d](9cda68d))
* **jobsdb:** multi-consumer-specific indexes and views
([#7093](#7093))
([61b41e4](61b41e4))
* **jobsdb:** multiconsumer flip, registry table and unionjobsdb
([#7094](#7094))
([9eff2e9](9eff2e9))
* **jobsdb:** new columns for multi-consumer jobsdb
([#7082](#7082))
([61b41e4](61b41e4))
* recreate stale rsources subscription on shared db
([#7108](#7108))
([c59e9e5](c59e9e5))
* use priority pool at migration start while polling for pending jobs
([#7128](#7128))
([254ae15](254ae15))

---
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 was referenced Jun 29, 2026
atzoum pushed a commit that referenced this pull request Jun 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.79.0-rc.2](v1.78.0...v1.79.0-rc.2)
(2026-06-29)


### Features

* support compressing payloads in reporting client
([#7124](#7124))
([365b530](365b530))
* support deltalake azure hierarchical namespace folders
([#7089](#7089))
([61b41e4](61b41e4))


### Bug Fixes

* **jobsdb:** compaction panics with pq error column js.consumer does
not exist at position
([#7133](#7133))
([f392a53](f392a53))
* panic in user transformer client due to timeout doesn't get recorded
by alerts
([#7116](#7116))
([61b41e4](61b41e4))
* partition migration restarts server on slow in-progress wait
([#7129](#7129))
([d63d597](d63d597))


### Miscellaneous

* **jobsdb:** capturing multi-consumer pending events
([#7121](#7121))
([dc382f7](dc382f7))
* **jobsdb:** cleanup legacy configuration flags
([#7122](#7122))
([58778d5](58778d5))
* **jobsdb:** multi-consumer compaction
([#7096](#7096))
([57f1ef5](57f1ef5))
* **jobsdb:** multi-consumer get and noresults cache handling
([#7095](#7095))
([9d5c58a](9d5c58a))
* **jobsdb:** multi-consumer get distinct consumers
([#7097](#7097))
([f68a56d](f68a56d))
* **jobsdb:** multi-consumer partition migration
([#7098](#7098))
([9cda68d](9cda68d))
* **jobsdb:** multi-consumer-specific indexes and views
([#7093](#7093))
([61b41e4](61b41e4))
* **jobsdb:** multiconsumer flip, registry table and unionjobsdb
([#7094](#7094))
([9eff2e9](9eff2e9))
* **jobsdb:** new columns for multi-consumer jobsdb
([#7082](#7082))
([61b41e4](61b41e4))
* recreate stale rsources subscription on shared db
([#7108](#7108))
([c59e9e5](c59e9e5))
* use priority pool at migration start while polling for pending jobs
([#7128](#7128))
([254ae15](254ae15))

---
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 pushed a commit that referenced this pull request Jun 30, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.79.0](v1.78.0...v1.79.0)
(2026-06-29)


### Features

* support compressing payloads in reporting client
([#7124](#7124))
([365b530](365b530))
* support deltalake azure hierarchical namespace folders
([#7089](#7089))
([61b41e4](61b41e4))


### Bug Fixes

* **jobsdb:** compaction panics with pq error column js.consumer does
not exist at position
([#7133](#7133))
([f392a53](f392a53))
* panic in user transformer client due to timeout doesn't get recorded
by alerts
([#7116](#7116))
([61b41e4](61b41e4))
* partition migration restarts server on slow in-progress wait
([#7129](#7129))
([d63d597](d63d597))


### Miscellaneous

* **jobsdb:** capturing multi-consumer pending events
([#7121](#7121))
([dc382f7](dc382f7))
* **jobsdb:** cleanup legacy configuration flags
([#7122](#7122))
([58778d5](58778d5))
* **jobsdb:** multi-consumer compaction
([#7096](#7096))
([57f1ef5](57f1ef5))
* **jobsdb:** multi-consumer get and noresults cache handling
([#7095](#7095))
([9d5c58a](9d5c58a))
* **jobsdb:** multi-consumer get distinct consumers
([#7097](#7097))
([f68a56d](f68a56d))
* **jobsdb:** multi-consumer partition migration
([#7098](#7098))
([9cda68d](9cda68d))
* **jobsdb:** multi-consumer-specific indexes and views
([#7093](#7093))
([61b41e4](61b41e4))
* **jobsdb:** multiconsumer flip, registry table and unionjobsdb
([#7094](#7094))
([9eff2e9](9eff2e9))
* **jobsdb:** new columns for multi-consumer jobsdb
([#7082](#7082))
([61b41e4](61b41e4))
* recreate stale rsources subscription on shared db
([#7108](#7108))
([c59e9e5](c59e9e5))
* use priority pool at migration start while polling for pending jobs
([#7128](#7128))
([254ae15](254ae15))

---
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