Skip to content

Do not leak quiescence timer goroutines after the runner stops - #2219

Open
Adham-Kiwan wants to merge 1 commit into
hashicorp:mainfrom
Adham-Kiwan:fix/quiescence-goroutine-leak
Open

Adham-Kiwan wants to merge 1 commit into
hashicorp:mainfrom
Adham-Kiwan:fix/quiescence-goroutine-leak

Conversation

@Adham-Kiwan

Copy link
Copy Markdown

Description

With wait (quiescence) enabled, each quiescence timer goroutine sends on Runner.quiescenceCh. That channel was unbuffered and its only receiver is the loop in Runner.Start. When the runner stopped, pending timers blocked forever and kept their templates alive.

The channel now has one slot per template. A template has at most one pending quiescence, because a new one is only created after the previous one has been received, so the send no longer blocks.

Testing

Added TestRunner_quiescenceTimerExitsWithoutReceiver. In a GitHub Actions run on my fork, go test ./manager/ passes with the fix (with a Consul 1.20 binary). With the old runner.go, the new test fails: the timer goroutine is still blocked after the runner stops. gofmt, go vet and golangci-lint pass for ./manager/.

Written with AI assistance (Claude Code).

Fixes #2206

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request. (Reverting the pull request is enough.)
  • If applicable, I've documented the impact of any changes to security controls. (No security controls are changed.)

🤖 Generated with Claude Code

Each quiescence timer goroutine sent on an unbuffered channel whose only
receiver is the loop in Runner.Start. Once the runner stopped, pending
timers blocked forever and kept their templates alive. Give the channel
one slot per template so the send never blocks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Adham-Kiwan
Adham-Kiwan requested review from a team as code owners November 26, 2026 18:57
@hashicorp-cla-app

Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

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.

Quiescence timer goroutine blocks forever on q.ch <- q.template once the Runner has stopped

1 participant