Uh oh!
There was an error while loading. Please reload this page.
gh-84649: Make TimedRotatingFileHandler use CTIME instead of MTIME - #24660
Conversation
the-knights-who-say-ni
commented
Feb 26, 2021
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
Uh oh!
There was an error while loading. Please reload this page.
martonivan
commented
Mar 4, 2021
I've rebased the branch, squashed the recent fix (about the NEWS typo) into the last commit, as it was partially recommended in the bug report about the flawed testing infrastructure: https://bugs.python.org/issue43382 |
This PR is stale because it has been open for 30 days with no activity. |
vsajip
commented
Sep 2, 2021
See my suggestion on the issue if you want to progress things further. |
martonivan
commented
Sep 4, 2021
Thanks Vinay, I'll implement the suggested and acceptable solution as soon as I get there and will update this merge request. |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM. I was just about to create the same issue.
serhiy-storchaka
commented
Mar 1, 2024
@martonivan, the mechanism for the CLA signing was changed, please sign the CLA again, it is necessary for merging. Thank you for your contribution. |
martonivan
commented
Mar 1, 2024
Unfortunately I cannot access to the email address that stands in the commit anymore. Tried to reword those commits and rebase the whole tree, but I may caused more issue than I solved. Could you please help me what would be the proper way to implement this change in the commits? |
JelleZijlstra
commented
Mar 1, 2024
Either open a new PR, or reapply your changes to main and force-push to this PR branch to get rid of the problematic changes. |
Well, it is complicated.
|
martonivan
commented
Mar 6, 2024
I've implemented many of the suggested changes, but realized a huge issue: on Linux, since ctime also changes when the data block changes (practically when mtime changes), the test that checks if only the birthdate is old enough for rotation will always fail. It would be nice the have statx implemented and birth date/creation date known there too, but this issue is already staling for a while: #19125 |
serhiy-storchaka
commented
Mar 7, 2024
It is okay if this part of the feature is not supported on all platforms. We should do the best of what is currently possible on every platform. The availability of these attributes also depends on the file system. |
The TimedRotatingFileHandler previously only used st_mtime attribute of the log file to detect whether it has to be rotate yet or not. In cases when the file is changed within the rotatation period the st_mtime is also updated to the current time and the rotation never happens. It's more appropriate to check the file creation time (st_ctime) instead. Whenever available, the more appropriate st_birthtime will be in use. (This feature is available on FreeBSD, MacOS and Windows at the moment.) If the st_mtime would be newer than st_ctime (e.g.: because the inode related to the file has been changed without any file content modification), then the earliest attribute will be used.
martonivan
commented
Mar 7, 2024
All the tests are green on the supported operating systems. |
@martonivan: when sync'ing with |
martonivan
commented
Mar 8, 2024
Noted for further contribution, I'm not sure if any further commits will be necessary for this one. |
This PR is stale because it has been open for 30 days with no activity. |
vstinner
commented
Jun 5, 2026
This change added |
The TimedRotatingFileHandler previously used MTIME attribute of the log
file to detect whether it has to be rotate yet or not. In cases when the
file is changed within the rotation period the MTIME is also updated
to the current time and the rotation never happens. It's more
appropriate to check the file creation time (CTIME) instead.
https://bugs.python.org/issue40469