Repository navigation
De-flake Hosting semantic-logging specs: 10 s for the logger, thread-safe test logger - #8624
Merged
Aaronontheweb merged 1 commit intoSep 24, 2026
Conversation
…make SemanticTestLogger thread-safe SemanticLoggingSpecs.MultipleNamedPropertiesTest failed on a 2-vCPU Windows agent: its AwaitAssertAsync gave up after 3 s with LogEntries empty. The captured line in the output carries the EVENT's timestamp (29.121), not the time the logger printed it; it sits right before "Disposing system" (32.426), i.e. the LoggerFactoryLogger actor (default dispatcher) most likely reached the event only as the 3 s ran out. Nothing was lost. - Both helpers' default AwaitAssertAsync timeout goes from 3 s to 10 s. - SemanticTestLogger prints the wall-clock time it logged at, so the next failure shows when the logger actually got to the event. - LogEntries becomes a ConcurrentQueue (written on the logger's thread, read on the test's; siblings Issue701SemanticLoggingRegressionSpecs and LogStateSnapshotSpecs already do this) and ReceivedLogs uses Interlocked.
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.
Akka.Hosting.Tests.Logging.SemanticLoggingSpecs.MultipleNamedPropertiesTest("Should handle multiple named properties in template") failed on a 2-vCPU Windows agent:Assertion did not pass within 3s — Expected _logger.LogEntries not to be empty. It showed up in a duplicate branch build of AOT-stack PR #8603's head. The PR build of the same commit passed the wholeAkka.Hosting.Testssuite.Cause: the logger was late, not lossy
The test output contains the captured line
[INFO][05:05:29.121Z] ... Order ORD-001 ..., which made it look as if the entry arrived in time and then vanished. But that timestamp is the event's, taken when the actor calledlog.Info, not the time the test logger printed it. xUnit's output buffer records no write times.In the buffer, the line sits right before "Disposing system" at 32.426. So the
LoggerFactoryLoggeractor, which runs on the default dispatcher, most likely reached the event only as the 3 s assertion ran out.SemanticTestLogger.Loghas no path that prints without recording, and the helper re-readsLogEntrieson every retry.Change
SemanticLoggingSpecs,WithContextSpecs) now wait 10 s instead of 3 s by default.SemanticTestLoggerprints the wall-clock time it logged the entry, so if this recurs the log will show when the logger actually got to it.LogEntriesbecomes aConcurrentQueue<LogEntry>, since it's written on the logger actor's thread and read on the test's.Issue701SemanticLoggingRegressionSpecsandLogStateSnapshotSpecsalready do this.ReceivedLogsnow usesInterlocked/Volatile. This doesn't fix the flake, but the oldList<T>was a real data race.This covers all 7 tests in
SemanticLoggingSpecsand all 4 inWithContextSpecs.Verification (local)