Skip to content

fix: handshake worker starve when loading external certificate#369

Open
bndcts wants to merge 1 commit intocaddyserver:masterfrom
bndcts:master
Open

fix: handshake worker starve when loading external certificate#369
bndcts wants to merge 1 commit intocaddyserver:masterfrom
bndcts:master

Conversation

@bndcts
Copy link

@bndcts bndcts commented Feb 13, 2026

addresses this issue #368 (comment)

  • Fix goroutine leak when using external certificate managers (e.g. Tailscale get_certificate)
  • External certs are not added to certmagic's in-memory cache, so the previous leader/waiter pattern caused waiters to recursively miss the cache, spawn new leaders, and accumulate
    goroutines indefinitely under concurrent load
  • Share the leader's result directly with waiting goroutines via a new certLoadWaiter struct, avoiding the cache round-trip for externally-managed certificates

}

// no other goroutine is currently trying to load this cert
waiter = &certLoadWaiter{done: make(chan struct{})}
Copy link
Member

Choose a reason for hiding this comment

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

Could we pool these maybe to avoid some allocations?

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.

2 participants