[SERVER-4499] without --logappend, rotate old log Created: 15/Dec/11  Updated: 11/Jul/16  Resolved: 03/Apr/12

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: 2.1.1

Type: Improvement Priority: Trivial - P5
Reporter: Richard Kreuter (Inactive) Assignee: Brandon Diamond
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-4109 logappend should be the default Closed
Related
related to SERVER-4797 automatically rotate mongo logs on a ... Closed
Participants:

 Description   

Given how useful the log file is, the server probably shouldn't default to erasing it. (This comes up in trainings a lot, that trivial operator errors can erase arbitrarily much useful historical information.) Could the server either default to logappend or try to rotate an existing log file on startup?



 Comments   
Comment by auto [ 04/Apr/12 ]

Author:

{u'login': u'', u'name': u'Brandon Diamond', u'email': u'brandon@10gen.com'}

Message: SERVER-4499: skip logpath test
Branch: master
https://github.com/mongodb/mongo/commit/159f33561fbb1076098338fa746f4d1cf63f59cc

Comment by auto [ 03/Apr/12 ]

Author:

{u'login': u'', u'name': u'Brandon Diamond', u'email': u'brandon@10gen.com'}

Message: SERVER-4499: Cross-platform test for log rotation
Branch: master
https://github.com/mongodb/mongo/commit/3c046f865fb248785c55c7128dfaf3c731f0aa2f

Comment by auto [ 03/Apr/12 ]

Author:

{u'login': u'', u'name': u'Brandon Diamond', u'email': u'brandon@10gen.com'}

Message: SERVER-4499: fixed log rotation + added test
Branch: master
https://github.com/mongodb/mongo/commit/1dacd20021e5797915da62e97867aa62ac3ae34e

Comment by Richard Kreuter (Inactive) [ 10/Feb/12 ]

I'm in favor of logappend-by-default. It's a minor incompatible change, we can clearly explain in the release notes, e.g., "--logappend is now the default. If you want to truncate the logfile at server startup, you should do so in your init script."

Comment by Brandon Diamond [ 10/Feb/12 ]

After pow-wowing with Richard and Dan C, it seems as though the existing behavior is getting a bit too grizzly (especially in the presence of forking, wherein we must perform a second set of validations up front so as to ensure we can write to the log after the fork).

We think the best way forward is to always append instead of the rotate logic currently in place (which causes an existing file to be renamed and a new file started).

Before committing this change, I wanted to make sure this would be okay with everyone.

Comment by Brandon Diamond [ 09/Feb/12 ]

Revisiting and writing tests.

Comment by Richard Kreuter (Inactive) [ 09/Feb/12 ]

Please write some tests for this. Cases you need to check for:

(1) log file exists at startup
(2) log file doesn't exist at startup
(3) logpath denotes a directory
(4) logpath denotes something else weird

Comment by Richard Kreuter (Inactive) [ 09/Feb/12 ]

By inspection, the new behavior is doing something incorrect when there isn't an existing log file:

$ ls -l /tmp/log
ls: /tmp/log: No such file or directory
$ ./mongod --logpath /tmp/log --fork
Thu Feb 9 17:26:30 Warning: soft rlimits too low. Number of files is 256, should be at least 1000
forked process: 10763
all output going to: /tmp/log
log file [/tmp/log] exists; copied to temporary file [/tmp/log.2012-02-09T22-26-30]
child process started successfully, parent exiting

Comment by auto [ 23/Dec/11 ]

Author:

{u'login': u'', u'name': u'Brandon Diamond', u'email': u'brandon@10gen.com'}

Message: SERVER-4499: avoid renaming non-reg files
Branch: master
https://github.com/mongodb/mongo/commit/4cb6d892d3332cdbc7a5009671dbde69f5998718

Comment by auto [ 22/Dec/11 ]

Author:

{u'login': u'', u'name': u'Brandon Diamond', u'email': u'brandon@10gen.com'}

Message: SERVER-4499: made log rotation more robust
Branch: master
https://github.com/mongodb/mongo/commit/993a4a55efffad18cd735db0adc6604be5d0e807

Comment by auto [ 22/Dec/11 ]

Author:

{u'login': u'', u'name': u'Brandon Diamond', u'email': u'brandon@10gen.com'}

Message: SERVER-4499: old log rotated, not clobbered
Branch: master
https://github.com/mongodb/mongo/commit/dc9fb4cc88aa3c4fd5cd7475901857ff29c5f438

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