Skip to content

fix(warehouse): hot-reload degraded workspaces without aborting restored uploads - #7564

Merged
shekhar-rudder merged 8 commits into
masterfrom
harness/RUD-3445-fix-warehouse-hot-reload-degrad-4bee1669
Nov 4, 2026
Merged

shekhar-rudder merged 8 commits into
masterfrom
harness/RUD-3445-fix-warehouse-hot-reload-degrad-4bee1669

Conversation

@rudder-devbox

@rudder-devbox rudder-devbox Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Description

Make Warehouse.degradedWorkspaceIDs reloadable and refresh each WatchConfig subscriber from its last backend snapshot. Protect the interval before BCM/router consumption by deferring uploads whose exact connection is still present in the full snapshot; preserve aborts for absent connections.

Linear Ticket

RUD-3445

Security

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

Validation

  • go test -race -count=1 ./warehouse/multitenant/... — passed.

  • go test -race -count=1 ./warehouse/router/... — passed.

  • go test -count=1 ./warehouse/multitenant ./warehouse/archive ./warehouse/api ./warehouse/internal/api — passed.

  • go vet ./..., go build ./..., make fmt, and git diff --check — passed.

  • make lint: golangci-lint reported 0 issues; actionlint passed. Simplify pass replaced duplicate test-stat setup with Router.loadStats(); other suggestions were rejected because they added work for the tiny list or required unfiltered data in BCM.

  • Local mini integration: skipped; rudder-server cannot run this checkout from source in the supported sandbox build tier.

⚠️ Known Issues

  • make lint does not finish successfully: its gitleaks security subtarget scans the existing commit history and reports 34 leaks. No security finding in the changed files was reported.
  • Live warehouse-master no-restart behavior was not exercised in mini; its stock rudder-server image does not contain these edits.

⚠️ Auto-review unresolved

Adversarial self-review surfaced findings that were not auto-fixed. Each carries its disposition — please evaluate before merging.

  • high: Older subscriber deliveries can overwrite the full connection snapshot — warehouse/multitenant/manager.go:193 — not auto-fixed (iteration budget exhausted)
  • medium: Legacy uploads can be checked against a stale workspace ID — warehouse/router/router.go:443 — not auto-fixed (iteration budget exhausted)

@rudder-devbox

rudder-devbox Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

👋 I'm rudder-devbox. I opened this PR from task RUD-3445.

Mention @devbox or @rudder-devbox and I'll act on it — on a top-level PR comment,
in a review summary, or on an inline comment on the diff. Without a mention I won't see it.

@rudder-devbox

rudder-devbox Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

CI showed two failures. TestApp/monitor_routers panicked at warehouse/app_test.go:379: cancellation can close WatchConfig before a router starts, so monitorDestRouters returns nil. I fixed the test to handle nil or an error wrapping context.Canceled.

The Snowflake job separately reported WARNING: DATA RACE in gosnowflake/[email protected]/transport.go:188 as parallel loads mutated a shared transport. That integration path and dependency are unchanged from master; the upstream race remains unresolved.

The warehouse test passed five runs under -race; the multitenant race test and warehouse build passed. GolangCI reported 0 issues. make lint stopped on 34 existing gitleaks findings in commit history.

95589f4

@rudder-devbox

rudder-devbox Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Knowledge distillation completed

@rudder-devbox

rudder-devbox Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

The warehouse unit job timed out in TestSlaveWorker/async_job: the test waited at worker_test.go:1002 for bcm.Start to finish, while the new WatchConfig subscription correctly stayed open until cancellation. I changed the test to cancel its setup context after the initial configuration arrives. The focused race test passes, and lint found 0 code issues. The full local slave test also encountered missing staging-bucket configuration in two earlier cases; the lint history scan still reports 34 existing findings.

The Snowflake integration job separately reports a race in gosnowflake/[email protected]/transport.go:188 during concurrent connection creation. That dependency race remains unresolved and may keep CI red.

89f0ce8

@rudder-devbox

rudder-devbox Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Knowledge distillation completed

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.46154% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.24%. Comparing base (69b43e0) to head (187dfd7).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
warehouse/multitenant/manager.go 98.41% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7564      +/-   ##
==========================================
+ Coverage   85.22%   85.24%   +0.01%     
==========================================
  Files         631      631              
  Lines       62990    63014      +24     
==========================================
+ Hits        53683    53716      +33     
+ Misses       9304     9295       -9     
  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.

- Replace HasConnection's (exists, known) pair with ConnectionRemoved, the
  single answer the router consumes.
- Drop the PseudoWarehouseDestinationMap check: routers only exist for
  warehouse destinations and the lookup already matches on destType.
- Filter with lo.OmitByKeys; return the reloadable slice without cloning.
- Close WatchConfig when the backend subscription closes, as before. That
  only happens on context cancellation in production, so the slave worker
  test no longer needs its own cancel.
- Only WatchConfig subscribers write the full snapshot; the router reads
  it, and routers only exist under a WatchConfig subscriber.
- Trim duplicated test code.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@rudder-devbox

rudder-devbox Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

I traced the ClickHouse failure to a lost database connection during TestIntegration/Events_flow_(JSON_paths). The first groups load completed, but the post-load row-count query failed with use of closed network connection. The router retried the same upload and loaded groups again; the assertion then saw 8 rows instead of 4.

This run has a transient ClickHouse connection failure, and the branch makes no ClickHouse load changes or degraded-workspace edits in that test. I made no code change: changing the expected count would conceal the duplicate load, while a source edit cannot repair the dropped test database connection. The integration job needs a rerun against a stable ClickHouse service; repeated occurrences warrant a separate idempotent-retry fix.

shekhar-rudder and others added 3 commits November 3, 2026 23:31
Every WatchConfig subscription wrote fullConfig from its own backend-config
subscription. pubsub orders snapshots per subscriber only, so a slow
subscriber could overwrite a newer snapshot with an older one.

Run is now the only backend-config subscriber and the only writer of
fullConfig; WatchConfig subscribers are signalled and filter the latest
snapshot, matching the single-writer fan-out used by bcm.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A new WatchConfig subscriber could receive the same snapshot twice: once
from its startup signal and once from Run's notification. Track the
snapshot version and degraded list last sent, and skip unchanged sends.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@rudder-devbox

rudder-devbox Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

The warehouse unit job timed out in TestRouter/Backend_config_subscriber, blocked at router_test.go:1318 waiting for BCM's initial config. That test started BCM but never started tenantManager.Run, which now owns the backend-config subscription and snapshot. I started the manager in the test before BCM.

The focused router test passed under -race. Formatting completed, and lint found 0 code issues. The full local router run timed out while setting up Postgres for an unrelated TestColumnCountStat case; the lint history scan still reports 34 existing findings.

d6d6856

@rudder-devbox

rudder-devbox Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Knowledge distillation completed

@rudder-devbox

rudder-devbox Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

The arm64 image build stopped at RUN go mod download, before source compilation. The log shows proxy.golang.org returning HTTP/2 INTERNAL_ERROR stream failures for golang.org/x/[email protected] and k8s.io/[email protected], then buildx exited 1. This is a transient dependency download failure, so I made no source change and re-queued the failed build job. Its new result is pending.

- Initialise the manager in New and drop the lazy init, the stored config
  and initOnce.
- Rename sourceMu to configMu now that it guards the full snapshot, and
  take a read lock in SourceToWorkspace.
- Bump one config version on snapshot and degraded-list changes so
  watchers dedupe on a single counter.
- Drop the scan for uploads without a workspace ID: every upload since the
  workspace_id column was added carries one, and the router resolves it
  before checking the connection.
- Reuse setupDB in the router pickup test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@shekhar-rudder
shekhar-rudder marked this pull request as ready for review November 4, 2026 07:08
Copilot AI balanced review requested due to automatic review settings November 4, 2026 07:08
Comment thread warehouse/multitenant/manager.go Resolved

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.

🟡 Changes recommended

Legacy uploads with an empty workspace ID can be incorrectly aborted during restoration because the connection check does not first resolve the workspace from the manager’s unfiltered source mapping.

1 open issue
What changed in this PR

This PR makes warehouse degradation settings reloadable and protects restored uploads while downstream configuration consumers catch up.

Changes:

  • Refresh filtered configuration subscribers when backend snapshots or degraded workspace settings change.
  • Defer uploads whose exact connection remains in the full snapshot, while preserving aborts for absent connections.
  • Add restoration and reload regression tests, and adjust test lifecycle handling.
File Description
warehouse/​slave/​worker_test.go Start the tenant manager and explicitly cancel BCM startup.
warehouse/​router/​router.go Check the full connection snapshot before aborting uploads.
warehouse/​router/​router_test.go Cover restoration gaps, initial snapshot delays, and removed connections.
warehouse/​multitenant/​manager.go Add reloadable degradation settings, shared snapshots, and subscriber notifications.
warehouse/​multitenant/​manager_test.go Test setting reloads, subscriber refreshes, and connection checks.
warehouse/​bcm/​backend_config_test.go Start the tenant manager for configuration subscriptions.
warehouse/​app_test.go Allow cancellation before an initial snapshot starts a router.

Review effort: Balanced

if m.fullConfig == nil {
return false
}
return !connectionInWorkspace(m.fullConfig[workspaceID], sourceID, destinationID, destType)

@lvrach lvrach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note: this review is part of an experiment, the #proj-auto-approve auto-approval process. No human looked at this PR. Auto-approve category: documented bug fix.

Approve. The reloadable degraded list removes the restart loop from INT-7503. Deferring uploads in the gap before BCM catches up is the right fix. CI is green on 187dfd7.

Should-fix 1: legacy uploads of a degraded workspace hold batch slots (warehouse/router/router.go:444).
The SQL skips degraded workspaces with workspace_id <> ALL ($4) (warehouse/internal/repo/upload.go:313). A row with an empty workspace_id passes that filter. The router then resolves it through workspaceBySourceIDs, which is never pruned, so it gets W. ConnectionRemoved(W, …) returns false because the full snapshot still holds the connection. The upload is deferred on every allocator cycle while W stays degraded. LIMIT runs before this check, so with one free worker this row can take the slot each cycle, and healthy workspaces wait. The old code aborted these rows.

Should-fix 2: legacy uploads can still abort just after restore (router.go:427-452).
Start with W degraded while another workspace keeps the router for this destination type running. W's source never enters workspaceBySourceIDs. Remove W from the list. Before the router consumes the restored config, a legacy upload resolves to "". ConnectionRemoved("", …) looks in fullConfig[""], returns true, and the upload is aborted. That is the outcome this PR prevents for normal rows.

Fix for both: resolve an empty workspace ID with tenantManager.SourceToWorkspace (unfiltered) before the removal check. Then skip uploads of degraded workspaces before they count against the limit, or refill the selection after a deferral.

Suggestion: make the deferral visible. The continue at line 444 has no log or stat. A counter by workspace and destination type shows when a deferral never ends.

Nits

  • WatchConfig reads the degraded list outside configMu. It causes at most one extra delivery.
  • New registers a reload observer that is never removed. This matters only in tests that build many managers.
  • app_test.go:379-383 now asserts less than before. Check that the weaker assertion is intended.

Checked and not an issue: the PR body's "older subscriber deliveries overwrite the snapshot" finding. Only Run writes fullConfig, and the queued signal delivers the latest version after any stale one.

@shekhar-rudder
shekhar-rudder merged commit cb98598 into master Nov 4, 2026
76 checks passed
@shekhar-rudder
shekhar-rudder deleted the harness/RUD-3445-fix-warehouse-hot-reload-degrad-4bee1669 branch November 4, 2026 12:37
This was referenced Nov 9, 2026
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.

5 participants