Skip to content

fix: lease lock release race and pipeline retry stall; injectable test timers - #24190

Open
kalverra wants to merge 4 commits into
DX-5066/db-testsfrom
DX-5066/speed-product-fixes
Open

kalverra wants to merge 4 commits into
DX-5066/db-testsfrom
DX-5066/speed-product-fixes

Conversation

@kalverra

@kalverra kalverra commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Intent

Two production bugs surfaced while chasing slow tests: a lease lock that stayed held when Release raced an in-flight refresh, and a retry backoff that outlived the run context during shutdown. This fixes both and makes two timers settable so the speed-ups in #24191 don't have to wait out their defaults. Part of DX-5066.

Changes

Release() cancelled the refresh query's connection, so the release statement ran on a dead connection and the lease stayed held:

Before: release on the cancelled connection

flowchart LR
  R["Release()"] --> C["cancel lease context"]
  C --> Q["in-flight refresh query dies"]
  Q --> X["release on dead conn: bad connection"]
  X --> H["lease held until it expires"]
Loading

After: fall back to a fresh connection

flowchart LR
  R["Release()"] --> C["cancel lease context"]
  C --> Q["in-flight refresh query dies"]
  Q --> X["release on dedicated conn fails"]
  X --> F["retry release on pool conn"]:::new
  F --> OK["lease freed immediately"]
  classDef new fill:#d4f8d4,stroke:#2da44e
Loading
Pipeline retries no longer sleep through a dead run context

DataSource.Close waits for running pipelines, and the retry goroutine only woke on failEarly, so a task with retries=2 delayed shutdown by up to 15s. scheduler.Run now takes the run context, stops retrying once it is done, and cuts any pending backoff short. Covered by TestScheduler_RunContextDoneCutsRetryBackoff.

Two intervals are now injectable, defaults unchanged

Notes

  • releaseLease has no regression test: reproducing the race needs the lock's private connection. The observed failure and the fix's 4-of-20 fallback rate are recorded in the commit message.
  • Behaviour at default settings is unchanged; the only visible effect is a faster shutdown and an immediate lease handover after a restart.

kalverra and others added 3 commits November 11, 2026 08:26
…e old one

Release cancels the lease loop's context. If that lands while a refresh
query is in flight, the cancelled query closes the dedicated connection,
the release UPDATE fails with "bad connection", and the lease stays held
until it expires. The next instance then waits out the full lease
duration (1 minute by default). Retry the release on a pooled connection.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The scheduler's retry goroutine slept through task backoff (5s + 10s with
retries=2) after the run context had expired, because it only woke on
failEarly. A retry cannot succeed once the run context is done, so
scheduler.Run now takes the run context, skips retries after it expires,
and ends a pending backoff wait. This also delayed node shutdown
(DataSource.Close waits on the in-flight run) by up to 15s.

Adds TestScheduler_RunContextDoneCutsRetryBackoff.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…l injectable

registrysyncer.New takes variadic options; WithTickInterval sets how often
the sync loop polls the registry (default stays 12s). The chip ingress
batch client's health-check interval is a field (default stays 5s) with
NewTestChipIngressBatchClientWithHealthInterval. Tests use short intervals
instead of waiting out the defaults. No behaviour change at the defaults.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ No conflicts with other open PRs targeting develop

@kalverra kalverra changed the title DX 5066/speed product fixes fix: lease lock release race and pipeline retry stall; injectable test timers Nov 11, 2026
The observation loop polls whatever stream set Observe last stored, and
nothing expired it. A node that falls behind in consensus stops getting
Observe calls, so its loop kept hitting adapters for streams the DON had
already tombstoned or removed.

Drop the set if Observe has not refreshed it within
max(10*T, 5s) and let the loop exit. The next Observe restarts it.

This was the cause of the TestIntegration_LLO_tombstone_stops_observations_and_reports
flake: one of four nodes lagged after a KV commit conflict, kept a stale
two-stream set, and bridge calls for the tombstoned stream never stopped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kalverra
kalverra requested a review from a team as a code owner November 11, 2026 21:21
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

CORA - Pending Reviewers

All codeowners have approved! ✅

Legend: ✅ Approved | ❌ Changes Requested | 💬 Commented | 🚫 Dismissed | ⏳ Pending | ❓ Unknown

For more details, see the full review summary.

@kalverra
kalverra removed this pull request from stack #24076 November 12, 2026 13:51
@kalverra
kalverra added this pull request to stack #24200 November 12, 2026 13:53
This was referenced Nov 12, 2026
@kalverra
kalverra removed this pull request from stack #24200 November 12, 2026 14:14
@kalverra
kalverra added this pull request to stack #24201 November 12, 2026 14:14

This branch has not been deployed

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