Repository navigation
Fix silent backup loss and test pollution in log rotation - #73
Open
Sherlock0203 wants to merge 1 commit into
Open
Sherlock0203 wants to merge 1 commit into
Sherlock0203 wants to merge 1 commit into
Conversation
Review fixes for the size based log rotation of apache#2696: The shift of the backups ignored the result of every rename, so when ".1" could not be moved to ".2" (a tail tool holding the backup open on Windows, a non-empty directory on the slot) the final rename went on anyway and silently replaced ".1" with the current file: every rotation dropped a generation while being accounted as a success. A shift that fails now aborts the rotation through the back off path and leaves every backup in place. The shift also renamed one index per --log_rotate_max_backups, which is only validated to be a positive int. A huge value turned every rotation into as many rename() calls under the logging lock, stalling both synchronous and asynchronous logging for minutes. Backups are numbered contiguously, so the highest existing one is probed and only the existing files are shifted. A rotation failure was never printed on Windows, and a log file that disappeared from under the process reset the back off: the ".\debug.log" that Windows falls back to when the requested name cannot be opened was then closed and reopened on every single log once over the limit. The error is now printed on every platform through SystemErrorCodeToString() and PathAsString(), and the disappeared file backs off too; the fresh file reopened under the original name is smaller, which lets rotation resume right away. LogRotationTest pointed the global logging destination at its temp file and never restored it: once CloseLogFile() had closed the handle, every later suite of test_butil appended to a file under that path and lost its stderr, leaving stray temp_file_XXXXXX files in the run directory. TearDown() now restores the default destination and also removes the obstacle directories that a failed test may leave behind. New tests: a failed shift keeps the newest backup (rotation resumes once the obstacle is gone); a huge --log_rotate_max_backups stays fast; threads logging synchronously through rotations lose and duplicate no log. docs/cn and docs/en now state that a backup which cannot be moved stops the rotation instead of being overwritten. StackTraceTest.find_symbol fails on the base commit of this branch (efef0e6) as well: pre-existing environment issue, unrelated.
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.
No description provided.