Skip to content

Prevent dashboard publisher starvation - #347

Closed
trask wants to merge 7 commits into
mainfrom
trask-fix-dashboard-publisher-contention
Closed

trask wants to merge 7 commits into
mainfrom
trask-fix-dashboard-publisher-contention

Conversation

@trask

@trask trask commented Sep 2, 2026

Copy link
Copy Markdown
Member

Prevents concurrent dashboard state updates from starving a publisher. State writers respect the repository publisher lease, while --force-with-lease handles races that begin before the lease commit.

Direct workflows wait for the publisher. Queue workers return every claim for a busy repository and retry after five minutes without using the processing-failure budget. Targeted updates and head-SHA claim resolution check the lease before GitHub API or Copilot work.

Fixes #341

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 2, 2026

Copy link
Copy Markdown

Pull request dashboard status

Closed · refreshed 2026-09-16 19:41 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Copilot AI 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.

🔵 Needs a closer look

Cross-process lease timing and CAS interactions warrant final human validation despite strong targeted coverage.

Pull request overview

Adds a publisher-aware write barrier to prevent state updates from starving dashboard publication.

Changes:

  • Waits for publisher leases before each state CAS attempt.
  • Applies a shared 40-minute queue lock-wait deadline.
  • Adds tests and updates concurrency documentation.
File summaries
File Description
state_branch.py Implements publisher barriers and shared deadlines.
dashboard.py Enables barriers for dashboard state writers.
process_queue_batch.py Bounds queue-wide lock waiting.
test_state_branch.py Tests barrier and deadline behavior.
test_dashboard.py Verifies writers respect publisher locks.
test_process_queue_batch.py Tests queue deadline environment handling.
RATIONALE.md Documents lease/CAS coordination.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI 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.

🔵 Needs a closer look

The distributed lease, CAS, and durable queue interactions warrant final human validation despite strong test coverage.

Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI 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.

🔵 Needs a closer look

Distributed lease, CAS, and durable-queue interactions warrant final human validation.

Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

trask and others added 3 commits September 15, 2026 08:14
Make dashboard state writers wait for active publisher leases before each CAS attempt, and bound queue-worker lock waits below the job timeout.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8c4a7acc-3827-4097-9d75-2d054cf9fc3f
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8c4a7acc-3827-4097-9d75-2d054cf9fc3f
Review finding:

This PR makes the scheduled dashboard-queue-recover function the normal restart path for work it defers, and raises its frequency from hourly to every five minutes for exactly that reason. RATIONALE.md now says the claims become runnable after the delay and a recovery scan runs every five minutes to start their next drain. WEBHOOK_SETUP.md still tells operators the opposite: it says a new event normally starts the singleton drain immediately and that scheduled recovery is only a failure backstop. After this change a publisher-lock deferral sets notBefore in the future, finishDispatcher reports nothing runnable, and no new event restarts the drain, so the scheduled scan is the ordinary path for that work. Fix: update the WEBHOOK_SETUP.md paragraph so it also names the scheduled scan as the path that restarts deferred queue work, instead of describing it purely as a failure backstop.

Analysis: A publisher-lock deferral acknowledges a claim as a retry with a five-minute delay, which sets notBefore in the future. claimWave and hasRunnableItems both skip an item until notBefore passes, so finishDispatcher finds nothing runnable and requests no successor drain. Nothing then restarts that work until either the scheduled dashboard-queue-recover scan sees the item as runnable and requests a dispatcher, or a later webhook event happens to arrive after the delay has elapsed. That is why this PR changed the function's schedule from hourly to every five minutes. WEBHOOK_SETUP.md is the operator-facing setup document, and its claim that scheduled recovery is only a failure backstop was accurate before this change, because production acknowledgments supplied no nonzero retry delay. This PR makes that sentence wrong and leaves an operator with no explanation for the new schedule.

The replacement paragraph states the schedule, names both restart paths, and keeps the dead-letter sentence unchanged. It avoids the evaluator's stronger wording that would have dropped the still-true fact that a new event normally starts the drain immediately.

Upsides: The setup document now matches the queue's behavior and explains why the recovery function runs every five minutes. An operator reading it will not treat a scan that starts a deferred drain as a sign that something failed.

Downsides: No material downside identified. The change is documentation only and touches no file this PR already changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@trask
trask force-pushed the trask-fix-dashboard-publisher-contention branch from d44904b to 14cf2a9 Compare September 15, 2026 15:19
@trask
trask requested a balanced review from Copilot September 15, 2026 17:44

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Comment thread .github/scripts/pull-request-dashboard/netlify/lib/dashboard-queue.mjs Outdated
Comment thread .github/scripts/pull-request-dashboard/process_queue_batch.py
Comment thread .github/scripts/pull-request-dashboard/process_queue_batch.py
Comment thread .github/scripts/pull-request-dashboard/state_branch.py
Copilot AI and others added 2 commits September 16, 2026 12:22
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Co-authored-by: trask <218610+trask@users.noreply.github.com>

Copilot AI 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.

🔵 Needs a closer look

Distributed lease, CAS, and durable retry interactions warrant final human concurrency review.

Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread .github/scripts/pull-request-dashboard/process_queue_batch.py
Comment thread .github/scripts/pull-request-dashboard/state_branch.py Outdated
Comment thread .github/scripts/pull-request-dashboard/process_queue_batch.py Outdated
Co-authored-by: trask <218610+trask@users.noreply.github.com>

Copilot AI 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.

🟡 Changes recommended

The refreshed lease ref can permit a stale force-push that discards publisher state.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +451 to +456
if respect_publisher_lock:
wait_for_publisher_unlock(
state_dir,
state_branch,
wait_seconds=publisher_lock_wait_seconds,
)
@trask

trask commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

Superseded by #383

@trask trask closed this Sep 16, 2026
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.

Workflow failed: Pull request dashboard (#242721)

3 participants