Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd9151d

Browse files
authored
fix(coderd/database/pubsub): prevent listeners read outside mutex lock (#15303)
https://github.com/coder/coder/actions/runs/11611105362/job/32331771969#logs```2024-10-31T11:36:45.9225038Z WARNING: DATA RACE2024-10-31T11:36:45.9225120Z Write at 0x00c0000d8030 by goroutine 26:2024-10-31T11:36:45.9225200Z runtime.mapdelete()2024-10-31T11:36:45.9225412Z /opt/hostedtoolcache/go/1.22.8/x64/src/runtime/map.go:696 +0x02024-10-31T11:36:45.9225647Z github.com/coder/coder/v2/coderd/database/pubsub.(*PGPubsub).subscribeQueue.func2()2024-10-31T11:36:45.9225906Z /home/runner/work/coder/coder/coderd/database/pubsub/pubsub.go:277 +0x1312024-10-31T11:36:45.9225993Z runtime.deferreturn()2024-10-31T11:36:45.9226210Z /opt/hostedtoolcache/go/1.22.8/x64/src/runtime/panic.go:602 +0x5d2024-10-31T11:36:45.9226283Z testing.tRunner()2024-10-31T11:36:45.9226519Z /opt/hostedtoolcache/go/1.22.8/x64/src/testing/testing.go:1689 +0x21e2024-10-31T11:36:45.9226603Z testing.(*T).Run.gowrap1()2024-10-31T11:36:45.9226831Z /opt/hostedtoolcache/go/1.22.8/x64/src/testing/testing.go:1742 +0x442024-10-31T11:36:45.9226836Z 2024-10-31T11:36:45.9226934Z Previous read at 0x00c0000d8030 by goroutine 112:2024-10-31T11:36:45.9227159Z github.com/coder/coder/v2/coderd/database/pubsub.(*PGPubsub).subscribeQueue.func2()2024-10-31T11:36:45.9227462Z /home/runner/work/coder/coder/coderd/database/pubsub/pubsub.go:284 +0x1b62024-10-31T11:36:45.9227661Z github.com/coder/coder/v2/enterprise/replicasync.(*Manager).subscribe.func3()2024-10-31T11:36:45.9227936Z /home/runner/work/coder/coder/enterprise/replicasync/replicasync.go:228 +0x532024-10-31T11:36:45.9227941Z 2024-10-31T11:36:45.9228019Z Goroutine 26 (running) created at:2024-10-31T11:36:45.9228096Z testing.(*T).Run()2024-10-31T11:36:45.9228318Z /opt/hostedtoolcache/go/1.22.8/x64/src/testing/testing.go:1742 +0x8252024-10-31T11:36:45.9228498Z github.com/coder/coder/v2/enterprise/replicasync_test.TestReplica()2024-10-31T11:36:45.9228777Z /home/runner/work/coder/coder/enterprise/replicasync/replicasync_test.go:33 +0x4b2024-10-31T11:36:45.9228847Z testing.tRunner()2024-10-31T11:36:45.9229063Z /opt/hostedtoolcache/go/1.22.8/x64/src/testing/testing.go:1689 +0x21e2024-10-31T11:36:45.9229142Z testing.(*T).Run.gowrap1()2024-10-31T11:36:45.9229366Z /opt/hostedtoolcache/go/1.22.8/x64/src/testing/testing.go:1742 +0x442024-10-31T11:36:45.9229369Z 2024-10-31T11:36:45.9229443Z Goroutine 112 (finished) created at:2024-10-31T11:36:45.9229685Z github.com/coder/coder/v2/enterprise/replicasync.(*Manager).subscribe()2024-10-31T11:36:45.9229952Z /home/runner/work/coder/coder/enterprise/replicasync/replicasync.go:226 +0x5682024-10-31T11:36:45.9230092Z github.com/coder/coder/v2/enterprise/replicasync.New()2024-10-31T11:36:45.9230361Z /home/runner/work/coder/coder/enterprise/replicasync/replicasync.go:101 +0x13442024-10-31T11:36:45.9230547Z github.com/coder/coder/v2/enterprise/replicasync_test.TestReplica.func1()2024-10-31T11:36:45.9230836Z /home/runner/work/coder/coder/enterprise/replicasync/replicasync_test.go:48 +0x26a2024-10-31T11:36:45.9230904Z testing.tRunner()2024-10-31T11:36:45.9231127Z /opt/hostedtoolcache/go/1.22.8/x64/src/testing/testing.go:1689 +0x21e2024-10-31T11:36:45.9231207Z testing.(*T).Run.gowrap1()2024-10-31T11:36:45.9231431Z /opt/hostedtoolcache/go/1.22.8/x64/src/testing/testing.go:1742 +0x44```
1 parentb1298a3 commitbd9151d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎coderd/database/pubsub/pubsub.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,11 @@ func (p *PGPubsub) subscribeQueue(event string, newQ *msgQueue) (cancel func(),
278278
iflen(listeners)==0 {
279279
delete(p.queues,event)
280280
}
281+
listenerCount:=len(listeners)
281282
p.qMu.Unlock()
282283
// as above, we must not hold the lock while calling into pgListener
283284

284-
iflen(listeners)==0 {
285+
iflistenerCount==0 {
285286
uErr:=p.pgListener.Unlisten(event)
286287
p.closeMu.Lock()
287288
deferp.closeMu.Unlock()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp