[SERVER-9358] Log rotation can overwrite previous log files Created: 16/Apr/13  Updated: 11/Jul/16  Resolved: 11/Apr/14

Status: Closed
Project: Core Server
Component/s: Logging, Security
Affects Version/s: None
Fix Version/s: 2.6.1, 2.7.0

Type: Bug Priority: Major - P3
Reporter: Eric Milkie Assignee: Spencer Brody (Inactive)
Resolution: Done Votes: 0
Labels: Auditing
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-4905 logRotate should conform to standard ... Closed
is related to SERVER-16821 Do not abort server when receiving mu... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Participants:

 Description   
Issue Status as of April 15, 2014

ISSUE SUMMARY
If one rotates the log twice within one second, the previously rotated log will get overwritten by the new log. This is because the timestamped filename is not unique and the rename() function clobbers the destination with no warning.

USER IMPACT
Users rotating a log more than once per second will lose all log information from the last log rotation up to that point.

Enterprise users using the 2.6.0 audit facility will also be affected by this issue, and issuing more than one log rotation per second will result in lost audit logs.

WORKAROUNDS
Wait more than 1 second between log rotations.

RESOLUTION
The rename() function no longer clobbers existing log files, but fails with an error message if the destination file already exists.

AFFECTED VERSIONS
All recent production releases up to 2.6.0 are affected.

PATCHES
The patch is included in the 2.6.1 production release.

Original description

If one rotates the log twice within one second, the previously rotated log will get overwritten by the new (and probably very small) log. This is because the timestamped filename is not unique and the rename() function clobbers the destination with no warning.



 Comments   
Comment by Githook User [ 14/Apr/14 ]

Author:

{u'username': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@mongodb.com'}

Message: SERVER-9358 Prevent logRotate twice in the same second from losing log data

(cherry picked from commit d53521c9534d579d44582bb06cb37d73ffeab931)
Branch: v2.6
https://github.com/mongodb/mongo/commit/279163e3802cf5b538b22eac9302419f0f7bb6f8

Comment by Githook User [ 11/Apr/14 ]

Author:

{u'username': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@mongodb.com'}

Message: SERVER-9358 Prevent logRotate twice in the same second from losing log data
Branch: master
https://github.com/mongodb/mongo/commit/d53521c9534d579d44582bb06cb37d73ffeab931

Generated at Thu Feb 08 03:20:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.