From c0073ce945bfe30dc38fc8dbf3ea44605490ecc3 Mon Sep 17 00:00:00 2001 From: Paul Wells Date: Wed, 16 Sep 2026 15:44:34 -0700 Subject: [PATCH] rtc tests: give the logger its own logging config init() handed the logger &config.DefaultConfig.Logging, so the leveler's mutex lived inside the global that NewConfig yaml-marshals. Marshalling reflectively copies the whole struct, mutex included, which raced the component-level lookups pion makes from its own goroutines and failed TestPreferMediaCodecForPublisher under -race. The values are the same; only the storage is now test-local. The integration helper aliased the same global and gets the same treatment. --- pkg/rtc/room_test.go | 6 +++++- test/integration_helpers.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/rtc/room_test.go b/pkg/rtc/room_test.go index 4f76d0705..23330652d 100644 --- a/pkg/rtc/room_test.go +++ b/pkg/rtc/room_test.go @@ -51,7 +51,11 @@ const ( ) func init() { - config.InitLoggerFromConfig(&config.DefaultConfig.Logging) + // the logger keeps this pointer, so it needs storage of its own: NewConfig + // yaml-marshals DefaultConfig, which reflectively copies the leveler's mutex + // while pion goroutines are locking it. + logging := config.LoggingConfig{PionLevel: config.DefaultConfig.Logging.PionLevel} + config.InitLoggerFromConfig(&logging) roomUpdateInterval = defaultDelay } diff --git a/test/integration_helpers.go b/test/integration_helpers.go index ec3469620..ba71c0560 100644 --- a/test/integration_helpers.go +++ b/test/integration_helpers.go @@ -63,7 +63,11 @@ const ( var roomClient livekit.RoomService func init() { - config.InitLoggerFromConfig(&config.DefaultConfig.Logging) + // the logger keeps this pointer, so it needs storage of its own: NewConfig + // yaml-marshals DefaultConfig, which reflectively copies the leveler's mutex + // while pion goroutines are locking it. + logging := config.LoggingConfig{PionLevel: config.DefaultConfig.Logging.PionLevel} + config.InitLoggerFromConfig(&logging) prometheus.Init("test", livekit.NodeType_SERVER) }