Skip to content

ctxwatch: ContextWatcher goroutine leak#2515

Merged
jackc merged 1 commit into
jackc:masterfrom
hdonnay:bug/1999
Mar 15, 2026
Merged

ctxwatch: ContextWatcher goroutine leak#2515
jackc merged 1 commit into
jackc:masterfrom
hdonnay:bug/1999

Conversation

@hdonnay

@hdonnay hdonnay commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

This fixes a goroutine leak that could occur if Unwatch was deferred a long time or was not called.

The mechanism now uses context.AfterFunc and a channel close, rather than a channel send+receive and boolean flags.

Closes: #1999

This fixes a goroutine leak that could occur if Unwatch was deferred a
long time or was not called.

The mechanism now uses `context.AfterFunc` and a channel close, rather
than a channel send+receive and boolean flags.

Closes: jackc#1999
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
@jackc jackc merged commit 799cdc2 into jackc:master Mar 15, 2026
14 checks passed
@jackc

jackc commented Mar 15, 2026

Copy link
Copy Markdown
Owner

Thanks. LGTM.

I was concerned about this simply masking a missing Unwatch call so I did a little investigating and found a couple potential paths which I fixed with a subsequent commit.

@hdonnay hdonnay deleted the bug/1999 branch March 16, 2026 16:21
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.

Ever Increasing number of Go routines with Pgx v5.5.5 and CockroachDB

2 participants