Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/database/sql: Close DB Stats goroutine on db.Close() #3025

Merged
merged 23 commits into from
Feb 3, 2025
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8f6d3a0
implement stopchan on contribroutines
mtoffl01 Dec 10, 2024
c7f7fd3
initialize channel at package root
mtoffl01 Dec 10, 2024
1b8bb5f
initialize stop channel at package root
mtoffl01 Dec 10, 2024
f0e844b
remove comment
mtoffl01 Dec 10, 2024
f0f73af
copywrite header
mtoffl01 Dec 10, 2024
bf4f376
Cleanup var declaration
mtoffl01 Dec 11, 2024
9e86acc
lock access to prevent race condition
mtoffl01 Dec 13, 2024
12241c9
added race detection tests to contribroutines_test.go
mtoffl01 Dec 16, 2024
41c3ad9
move stop chan initialization out of pollDBStats
mtoffl01 Dec 16, 2024
2cb3519
Apply stopchan to pgx pollPoolStats
mtoffl01 Dec 16, 2024
37b52f9
move lock outside of once.Do
mtoffl01 Dec 16, 2024
291e014
Merge branch 'main' into mtoff/contrib-routines
mtoffl01 Jan 13, 2025
11f13fa
Hook pollDBStats stop condition into db.Close() invocation
mtoffl01 Jan 13, 2025
42935d6
nits
mtoffl01 Jan 13, 2025
3fc1121
make tracer initialize new contribroutines.stop channel on startup
mtoffl01 Jan 13, 2025
5b116f8
Add reminder: implement stop condition on db.Close for pgx
mtoffl01 Jan 14, 2025
79ee5f5
revamp: tie pollDBStats to lifetime of db connection, only
mtoffl01 Jan 17, 2025
5bb8a4c
remove unused helper fn
mtoffl01 Jan 17, 2025
7b93aa2
nits: cleanup comments, fix undefined code call in metrics_test.go
mtoffl01 Jan 23, 2025
b55e322
Update godoc for tracedConnector.Close
mtoffl01 Jan 27, 2025
1ebd386
Merge branch 'main' into mtoff/contrib-routines
mtoffl01 Jan 31, 2025
8823e71
Merge branch 'main' into mtoff/contrib-routines
kakkoyun Feb 3, 2025
823375a
Merge branch 'main' into mtoff/contrib-routines
darccio Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lock access to prevent race condition
mtoffl01 committed Dec 13, 2024
commit 9e86accc1f9a5e4d531c76645888ed800c9289bd
5 changes: 5 additions & 0 deletions internal/contribroutines/contribroutines.go
Original file line number Diff line number Diff line change
@@ -9,14 +9,19 @@ import "sync"
var (
stop chan struct{} = make(chan struct{})
once sync.Once
mu sync.Mutex
)

func Stop() {
once.Do(func() {
mu.Lock()
defer mu.Unlock()
close(stop)
})
}

func GetStopChan() 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.

Suggested change
func GetStopChan() chan struct{} {
func StopChan() chan struct{} {

This would be a better name.

mu.Lock()
defer mu.Unlock()
return stop
}