Repository navigation
De-flake LoggerStartupSpec: gate the slow logger instead of racing a fixed delay - #8621
Merged
Aaronontheweb merged 1 commit intoSep 24, 2026
Conversation
…d 1 s delay ActorSystem_should_start_with_loggers_timing_out failed on a 2-vCPU Windows agent: the test subscribes its probe to the EventStream after ActorSystem.Create returns, but on a starved agent the slow logger's 1 s delay elapsed first and LoggingBus published its one-shot "Logger ... started" Debug 1 ms before the subscription existed. The EventStream doesn't replay, so the sync ExpectMsg<Debug> ate the whole AwaitAssert budget. SlowLoggerActor now answers InitializeLogger only when the test opens a gate, after it has subscribed. The gate is shut for all of Create, so the logger still always misses the 100 ms logger-startup-timeout - which is what the test is about - and the started Debug can no longer be published before anyone is listening. The two sync ExpectMsg-inside-AwaitAssert checks become FishForMessageAsync, since both probes also receive other messages.
Aaronontheweb
commented
Sep 24, 2026
Aaronontheweb
left a comment
Member
Author
There was a problem hiding this comment.
more deterministic than the previous Task.Delay solution - LGTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LoggerStartupSpec.ActorSystem_should_start_with_loggers_timing_out(useAsync: True)failed on a 2-vCPU Windows agent withTimeout 00:00:03 while waiting for a message of type Akka.Event.Debug. It appeared in a build of AOT-stack PR #8608.Not caused by the AOT stack
The stack changes
LoggingBus.StartDefaultLoggers(#8603), so I checked that first:Settings.csdiff betweendevand the stack is empty.SlowLoggerActorfalls through to the sameType.GetTypecall.Task.WaitAll(logger-startup-timeout)block and the log messages it publishes are byte-identical.Cause: publish before subscribe
SlowLoggerActoranswersInitializeLoggerafter a fixed 1 s.logger-startup-timeoutis 100 ms, soActorSystem.Creategives up waiting and returns.Debug, "Logger … SlowLoggerActor … started", once the logger answers.logProbeto the EventStream only afterCreatereturns.Createstalled about 900 ms. TheDebugwent out at 53.582 and the subscription happened at about 53.583. The EventStream doesn't replay old messages, so the synchronousExpectMsg<Debug>spent the wholeAwaitAssertbudget waiting.useAsync: Falsehas the same exposure, becauseakka.logger-async-startisn't read anywhere at runtime.Change
SlowLoggerActornow replies toInitializeLoggerwhen a gate the test controls opens (Release.Task.PipeTo), not after a fixed delay.Create, so the logger still always misses the 100 ms window. That's the behavior under test.Debugcan't be published before anyone is listening. Thefinallyblock releases the gate.ExpectMsgcalls insideAwaitAssertAsyncbecomeFishForMessageAsyncwith a 5 s bound, because both probes also receive other messages.Createdoesn't throw, LoggingBus reports the slow logger started after the timeout, and the logger then receives log events.An alternative was capturing the
Debugwith aLogFilterSetup. It wouldn't work here: the filter is only consulted byStandardOutLogger, and this spec replaces that withXUnitOutLogger.Verification (local)
LoggerStartupSpecpasses 6/6, five runs in a row, about 2 s faster than before.