Skip to content

fix(jobsdb): pickups stalling on status tables with skewed stats - #7572

Merged
atzoum merged 1 commit into
masterfrom
fix/jobsdb-status-job-id-n-distinct
Nov 9, 2026
Merged

atzoum merged 1 commit into
masterfrom
fix/jobsdb-status-job-id-n-distinct

Conversation

@atzoum

@atzoum atzoum commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

A status table analyzed while it holds a few heavily retried jobs keeps a tiny n_distinct statistics value for the job_id column. As the table grows, the planner can start resolving each job's latest status by walking the id index backwards, so pickups end up burning a full cpu core until the query timeout.

New status tables now pin a ratio through JobsDB.<prefix>.statusJobIDNDistinct, based on status rows per job: proc -0.1 (up to 10), others -0.5. 0 disables it. Existing tables are left as they are. TestStatusJobIDNDistinctPickup reproduces the stall and shows that pinning prevents it.

Linear Ticket

n/a

Security

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

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings November 4, 2026 17:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the configurable job ID statistics overrides on newly created status tables.

No open issues 🎉

What changed in this PR

This PR addresses jobsdb pickup stalls caused by skewed PostgreSQL statistics by pinning the estimated ratio of distinct job IDs on newly created status tables. Existing tables remain unchanged.

Changes:

  • Adds configurable, prefix-specific n_distinct defaults: gw −0.25, proc −0.1, and others −0.5.
  • Applies valid negative ratios during table creation; zero disables the override.
  • Adds tests for defaults, configuration handling, and statistics stored by ANALYZE.
File Description
jobsdb/​jobsdb.go Adds the reloadable statistics configuration field.
jobsdb/​jobsdb_status_ndistinct_test.go Tests defaults, overrides, and PostgreSQL statistics.
jobsdb/​jobsdb_dataset_ddl.go Sets job_id statistics overrides on new status tables.
jobsdb/​jobsdb_config.go Loads the configuration and defines prefix-specific defaults.

Review effort: Balanced

@atzoum
atzoum force-pushed the fix/jobsdb-status-job-id-n-distinct branch from ee9c2d9 to 8bbec32 Compare November 4, 2026 18:00
Copilot AI balanced review requested due to automatic review settings November 4, 2026 18:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the statistics override on newly created status tables.

No open issues 🎉

Review effort: Balanced

@atzoum
atzoum force-pushed the fix/jobsdb-status-job-id-n-distinct branch from 8bbec32 to 58ad722 Compare November 4, 2026 18:09
Copilot AI balanced review requested due to automatic review settings November 4, 2026 18:09
@atzoum
atzoum force-pushed the fix/jobsdb-status-job-id-n-distinct branch from 58ad722 to 374f5c2 Compare November 4, 2026 18:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the change targeting jobsdb pickup stalls caused by skewed PostgreSQL statistics.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 4, 2026 18:11
@atzoum
atzoum force-pushed the fix/jobsdb-status-job-id-n-distinct branch from 374f5c2 to 3591d5d Compare November 4, 2026 18:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The planner-statistics change affects all new jobsdb status tables, but the single-consumer regression leaves multi-consumer behavior uncovered, and representative PostgreSQL plan and latency validation cannot be run in this review environment.

No open issues 🎉

Review effort: Balanced

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.20%. Comparing base (573271b) to head (c3de6f9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7572   +/-   ##
=======================================
  Coverage   85.20%   85.20%           
=======================================
  Files         631      631           
  Lines       63050    63058    +8     
=======================================
+ Hits        53719    53728    +9     
+ Misses       9328     9327    -1     
  Partials        3        3           

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

@atzoum
atzoum force-pushed the fix/jobsdb-status-job-id-n-distinct branch from 3591d5d to 250aba3 Compare November 5, 2026 09:54
Copilot AI balanced review requested due to automatic review settings November 5, 2026 09:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the status-table statistics change.

No open issues 🎉

Review effort: Balanced

@atzoum
atzoum force-pushed the fix/jobsdb-status-job-id-n-distinct branch from 250aba3 to b021ecb Compare November 5, 2026 13:24
Copilot AI balanced review requested due to automatic review settings November 5, 2026 13:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The fix depends on PostgreSQL planner behavior, so the stall regression and representative multi-consumer query plans need runtime validation to establish the default ratios' performance impact.

No open issues 🎉

Review effort: Balanced

@mihir20 mihir20 left a comment

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.

LGTM

@atzoum
atzoum force-pushed the fix/jobsdb-status-job-id-n-distinct branch from b021ecb to c3de6f9 Compare November 6, 2026 10:15
Copilot AI balanced review requested due to automatic review settings November 6, 2026 10:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The planner-estimate override affects all new status tables, but database-backed validation of the timeout reproducer and multi-consumer -0.1 setting across representative workloads and supported PostgreSQL versions remains outstanding.

No open issues 🎉

Review effort: Balanced

@atzoum
atzoum merged commit 318446f into master Nov 9, 2026
75 checks passed
@atzoum
atzoum deleted the fix/jobsdb-status-job-id-n-distinct branch November 9, 2026 09:05
This was referenced Nov 9, 2026
atzoum pushed a commit that referenced this pull request Nov 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.93.0-rc.1](v1.92.0...v1.93.0-rc.1)
(2026-11-09)


### Features

* **destination:** recognize machine_oauth accounts as oauth
([#7549](#7549))
([f51e4ca](f51e4ca))
* incremental definitions on the v2 namespace config
([#7487](#7487))
([ce51e38](ce51e38))
* **processor:** add flag to abort python transformations on deployments
that do not offer them
([#7571](#7571))
([ca85eb2](ca85eb2))
* **processor:** filter http v2 events by destination message types
([#7538](#7538))
([58fd176](58fd176))
* **processor:** send the workspace id to per-workspace pyt pods
([#7551](#7551))
([ea33835](ea33835))
* **warehouse:** add maxcompute destination
([#7568](#7568))
([a64bfd9](a64bfd9))


### Bug Fixes

* **batchrouter:** abort bq stream all events jobs on terminal auth
failures
([#7548](#7548))
([6b7e023](6b7e023))
* bump andybalholm/brotli to v1.2.7 [SEC-759]
([#7525](#7525))
([6dfe468](6dfe468))
* bump rudder-go-kit to v0.84.3
([#7547](#7547))
([355054a](355054a))
* **core:** schema forwarder panics on shutdown
([#7519](#7519))
([dd61cfc](dd61cfc))
* database connections hang when context is cancelled during a copy
([#7578](#7578))
([8dae6e3](8dae6e3))
* **jobsdb:** compaction missing pairs after one that doesn't fit
([#7574](#7574))
([573271b](573271b))
* **jobsdb:** multiconsumer recovery misses a consumer's executing
status after another consumer's later status
([#7554](#7554))
([69b43e0](69b43e0))
* **jobsdb:** old jobs not expiring for every consumer
([#7573](#7573))
([366f114](366f114))
* **jobsdb:** pickups stalling on status tables with skewed stats
([#7572](#7572))
([318446f](318446f))
* **jobsdb:** unionjobsdb functions pick the first datasets by table
name ([#7558](#7558))
([e94d6c5](e94d6c5))
* **router:** event order test only counts drained jobs of the last
dataset
([#7552](#7552))
([b0a097a](b0a097a))
* **router:** mask secrets in array-shaped reporting samples
([#7536](#7536))
([902160f](902160f))
* **warehouse:** hot-reload degraded workspaces without aborting
restored uploads
([#7564](#7564))
([cb98598](cb98598))
* **warehouse:** match deltalake columns case-insensitively
([#7563](#7563))
([a7d30d7](a7d30d7))
* **warehouse:** migrate snowflake to gosnowflake v2.3.0
([#7542](#7542))
([cc09426](cc09426))
* **warehouse:** skip job-creation error log on router shutdown
([#7567](#7567))
([895367e](895367e))


### Miscellaneous

* **deps:** bump github.com/go-jose/go-jose/v4 from 4.1.4 to 4.1.6
([#7545](#7545))
([35ee952](35ee952))
* export only the +Inf bucket for limiter timers
([#7570](#7570))
([4429472](4429472))
* **router:** add drainReason label to pipeline_processed_events
([#7561](#7561))
([af0aef8](af0aef8))
* sync release v1.92.0 to main branch
([#7534](#7534))
([9ab165d](9ab165d))
* **warehouse:** bump sqlconnect-go to v1.37.1
([#7575](#7575))
([acdad67](acdad67))

---
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 Nov 10, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.93.0](v1.92.0...v1.93.0)
(2026-11-09)


### Features

* **destination:** recognize machine_oauth accounts as oauth
([#7549](#7549))
([f51e4ca](f51e4ca))
* incremental definitions on the v2 namespace config
([#7487](#7487))
([ce51e38](ce51e38))
* **processor:** add flag to abort python transformations on deployments
that do not offer them
([#7571](#7571))
([ca85eb2](ca85eb2))
* **processor:** filter http v2 events by destination message types
([#7538](#7538))
([58fd176](58fd176))
* **processor:** send the workspace id to per-workspace pyt pods
([#7551](#7551))
([ea33835](ea33835))
* **warehouse:** add maxcompute destination
([#7568](#7568))
([a64bfd9](a64bfd9))


### Bug Fixes

* **batchrouter:** abort bq stream all events jobs on terminal auth
failures
([#7548](#7548))
([6b7e023](6b7e023))
* bump andybalholm/brotli to v1.2.7 [SEC-759]
([#7525](#7525))
([6dfe468](6dfe468))
* bump rudder-go-kit to v0.84.3
([#7547](#7547))
([355054a](355054a))
* **core:** schema forwarder panics on shutdown
([#7519](#7519))
([dd61cfc](dd61cfc))
* database connections hang when context is cancelled during a copy
([#7578](#7578))
([8dae6e3](8dae6e3))
* **jobsdb:** compaction missing pairs after one that doesn't fit
([#7574](#7574))
([573271b](573271b))
* **jobsdb:** multiconsumer recovery misses a consumer's executing
status after another consumer's later status
([#7554](#7554))
([69b43e0](69b43e0))
* **jobsdb:** old jobs not expiring for every consumer
([#7573](#7573))
([366f114](366f114))
* **jobsdb:** pickups stalling on status tables with skewed stats
([#7572](#7572))
([318446f](318446f))
* **jobsdb:** unionjobsdb functions pick the first datasets by table
name ([#7558](#7558))
([e94d6c5](e94d6c5))
* **router:** event order test only counts drained jobs of the last
dataset
([#7552](#7552))
([b0a097a](b0a097a))
* **router:** mask secrets in array-shaped reporting samples
([#7536](#7536))
([902160f](902160f))
* **warehouse:** hot-reload degraded workspaces without aborting
restored uploads
([#7564](#7564))
([cb98598](cb98598))
* **warehouse:** match deltalake columns case-insensitively
([#7563](#7563))
([a7d30d7](a7d30d7))
* **warehouse:** migrate snowflake to gosnowflake v2.3.0
([#7542](#7542))
([cc09426](cc09426))
* **warehouse:** skip job-creation error log on router shutdown
([#7567](#7567))
([895367e](895367e))


### Miscellaneous

* **deps:** bump github.com/go-jose/go-jose/v4 from 4.1.4 to 4.1.6
([#7545](#7545))
([35ee952](35ee952))
* export only the +Inf bucket for limiter timers
([#7570](#7570))
([4429472](4429472))
* **router:** add drainReason label to pipeline_processed_events
([#7561](#7561))
([af0aef8](af0aef8))
* sync release v1.92.0 to main branch
([#7534](#7534))
([9ab165d](9ab165d))
* **warehouse:** bump sqlconnect-go to v1.37.1
([#7575](#7575))
([acdad67](acdad67))

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