gh-84649: Fix unstable test_rollover_at_midnight#154463
Merged
serhiy-storchaka merged 1 commit intoJul 22, 2026
Merged
Conversation
Create the log file in a fresh directory under a name which has never been used. On Windows, NTFS file tunneling restored the original creation time of a file recreated with the same name, which made the rollover time earlier than the current time and caused an unwanted rollover. Also check that the rollover does not happen before the specified time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka
enabled auto-merge (squash)
July 22, 2026 10:09
Member
Oh wow, that's a surprising issue! Using a temporary directory sounds like a reasonable fix for this issue. Thanks for fixing it, it was failing randomly on CIs for a few weeks. |
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.
The test was still unstable on Windows after GH-151813.
TimedRotatingFileHandlerbases the rollover time onint(min(creation_time, modification_time)). The test unlinked the file created insetUp()and recreated it under the same name, and on Windows NTFS file tunneling restores the original creation time in that case. The rollover time was therefore earlier than the current time, and the first records were unexpectedly rolled over. This pre-created the rotated file, so the real rollover hit theif os.path.exists(dfn): returncheck indoRollover()and the following records were not rolled over.Creating the log file in a fresh directory under a name which has never been used avoids tunneling.
On a Windows 11 VM the current test fails 6 times out of 40 runs, the fixed test 0 out of 120.
The test now also checks that the rollover does not happen before the specified time.
🤖 Generated with Claude Code