Mathias Fredriksson
bd9151d224
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 RACE
2024-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 +0x0
2024-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 +0x131
2024-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 +0x5d
2024-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 +0x21e
2024-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 +0x44
2024-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 +0x1b6
2024-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 +0x53
2024-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 +0x825
2024-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 +0x4b
2024-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 +0x21e
2024-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 +0x44
2024-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 +0x568
2024-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 +0x1344
2024-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 +0x26a
2024-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 +0x21e
2024-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
```
2024-11-01 11:24:29 +04:00
..
2024-11-01 14:17:05 +11:00
2024-03-13 12:03:36 +02:00
2024-11-01 14:53:53 +11:00
2024-06-03 12:29:50 -05:00
2024-09-18 21:47:53 +10:00
2024-10-31 17:55:42 -05:00
2024-10-30 10:20:47 -04:00
2023-10-30 19:44:29 +00:00
2024-05-28 16:45:41 +00:00
2024-10-31 17:55:42 -05:00
2024-10-28 20:31:01 +00:00
2024-11-01 11:24:29 +04:00
2024-05-23 08:22:44 -04:00
2024-10-05 06:58:43 +04:00
2024-09-04 18:17:53 +10:00
2023-08-18 18:55:43 +00:00
2024-09-16 20:02:08 +00:00
2024-10-24 15:12:35 -04:00
2024-10-31 17:55:42 -05:00
2024-07-11 13:38:33 -06:00
2024-10-25 12:14:15 -04:00
2024-10-25 17:14:35 +01:00
2024-10-22 09:20:54 -05:00
2024-10-31 17:01:51 +00:00
2024-01-10 09:13:30 -06:00
2024-05-13 14:37:51 -04:00
2024-10-30 18:41:16 +00:00
2024-10-25 12:14:15 -04:00
2024-11-01 14:17:05 +11:00
2024-07-25 16:08:12 -05:00
2024-10-31 17:01:51 +00:00
2024-07-08 15:38:50 +02:00
2024-09-16 19:03:25 -05:00
2024-10-22 09:20:54 -05:00
2024-08-28 15:18:45 -05:00
2024-10-22 09:20:54 -05:00
2024-10-25 15:14:39 +01:00
2024-03-17 22:08:32 -05:00
2024-10-22 09:20:54 -05:00
2023-10-30 17:42:20 +00:00
2024-03-26 20:47:14 -05:00
2024-10-22 09:20:54 -05:00
2024-10-25 17:14:35 +01:00
2024-11-01 14:17:05 +11:00
2024-10-25 12:14:15 -04:00
2024-11-01 14:17:05 +11:00
2024-10-17 05:37:43 +00:00
2024-10-01 09:01:24 +00:00
2024-09-18 21:23:42 +10:00
2023-08-18 18:55:43 +00:00
2024-08-01 12:07:19 -05:00
2024-08-01 12:07:19 -05:00
2024-10-22 13:47:30 +01:00
2024-07-19 15:44:18 -05:00
2024-07-29 19:58:48 -05:00
2023-08-18 18:55:43 +00:00
2024-10-22 09:20:54 -05:00
2024-11-01 14:53:53 +11:00
2023-08-18 18:55:43 +00:00
2024-03-26 12:44:31 -05:00
2024-09-03 10:32:33 -05:00
2024-02-27 16:33:32 +00:00
2024-05-15 11:09:42 -05:00
2024-06-11 12:22:59 +10:00
2023-10-17 14:49:19 -04:00
2023-10-17 14:49:19 -04:00
2024-09-10 15:58:50 +01:00
2024-09-10 15:58:50 +01:00
2024-10-25 15:14:39 +01:00
2024-10-25 15:14:39 +01:00
2024-07-30 10:44:02 -06:00
2023-09-01 16:50:12 +00:00
2024-10-07 21:10:01 +02:00
2024-10-25 16:49:44 +00:00
2024-06-03 15:48:31 +02:00
2023-06-06 10:26:13 -05:00
2024-09-17 10:42:47 -05:00
2024-09-26 11:48:50 -05:00
2024-10-01 13:43:47 +00:00
2024-08-05 16:18:45 +02:00
2024-03-25 11:52:22 -08:00
2024-07-11 13:38:33 -06:00
2024-07-25 16:07:53 -05:00
2024-08-28 13:24:28 -05:00
2024-03-05 14:05:15 +00:00
2024-06-28 07:38:04 -05:00
2024-01-04 18:35:56 -06:00
2024-07-30 10:44:02 -06:00
2023-12-18 22:53:28 +10:00
2024-07-25 16:07:53 -05:00
2024-08-05 13:42:11 -05:00
2024-02-14 20:45:31 +04:00
2024-10-04 10:04:10 +04:00
2024-10-23 10:09:56 +04:00
2024-10-15 21:02:02 +02:00
2024-10-31 17:01:51 +00:00
2024-08-06 11:26:26 -06:00
2024-09-06 16:13:34 +10:00
2023-08-18 18:55:43 +00:00
2023-08-18 18:55:43 +00:00
2024-10-31 17:55:42 -05:00
2024-10-31 17:55:42 -05:00
2024-10-31 17:55:42 -05:00
2024-10-31 17:55:42 -05:00
2024-10-22 09:20:54 -05:00
2024-05-13 14:37:51 -04:00
2024-11-01 14:53:53 +11:00
2024-11-01 14:53:53 +11:00
2024-11-01 14:17:05 +11:00
2024-10-25 16:49:44 +00:00
2024-11-01 14:17:05 +11:00
2024-10-25 17:14:35 +01:00
2024-10-25 17:14:35 +01:00
2024-10-22 09:20:54 -05:00
2024-11-01 14:53:53 +11:00
2024-01-18 09:44:05 -06:00
2024-01-18 09:44:05 -06:00
2024-07-30 10:44:02 -06:00
2023-08-18 18:55:43 +00:00
2024-10-31 12:33:07 -04:00
2024-11-01 14:17:05 +11:00
2024-11-01 14:53:53 +11:00
2024-11-01 14:53:53 +11:00