Description of problem: logrotate for mongodb logrotate file creates an additional file How reproducible: always Steps to Reproduce: 1. Run "logrotate -f /etc/logrotate.conf" Actual results: mongodb logrotate creates two files. Expected results: The logrotate should only create one file. Additional info: ls looks as follows: -rw-r--r--. 1 mongodb mongodb 0 Jan 11 18:35 mongod.log -rw-r--r--. 1 mongodb mongodb 1168 Dec 20 03:06 mongod.log-20151220.gz -rw-r--r--. 1 mongodb mongodb 493 Dec 27 03:40 mongod.log-20151227.gz -rw-r--r--. 1 mongodb mongodb 493 Jan 3 13:37 mongod.log-20160103.gz -rw-r--r--. 1 mongodb mongodb 2843 Jan 11 18:35 mongod.log-20160111 -rw-r--r--. 1 mongodb mongodb 0 Dec 20 03:06 mongod.log.2015-12-20T02-06-01 -rw-r--r--. 1 mongodb mongodb 0 Dec 27 03:40 mongod.log.2015-12-27T02-40-01 -rw-r--r--. 1 mongodb mongodb 0 Jan 3 13:37 mongod.log.2016-01-03T12-37-01 This is due to mongodb having its own logrotate on SIGUSR1 signal. As we have "copyontruncate" set, the USR1 is not needed. So we could just remove the postrotate action from the logrotate: # cat /etc/logrotate.d/mongodb /var/log/mongodb/*.log { weekly rotate 10 copytruncate delaycompress compress notifempty missingok ==> postrotate ==> /bin/kill -USR1 `cat /var/run/mongodb/mongod.pid 2>/dev/null` 2> /dev/null|| true ==> endscript } See also https://docs.mongodb.com/v2.6/reference/command/logRotate/ for some additional information.
Created attachment 1274781 [details] Patch to fix logrotate file
Can you please review the attached patch and merge if you're ok with it.Thanks!
Created attachment 1274785 [details] Fix for logrotate
Hi, upstream introduced fix for this in MongoDB 3.0 - https://docs.mongodb.com/v3.0/tutorial/rotate-log-files/#log-rotation-with-logrotate-reopen (this option improve working with logrotate utility and solves this problem). All versions of Fedora uses MongoDB 3.0+, so they should not have this problem. Have you tested this bug in Fedora? For MongoDB 2.6 in EPEL7 I hope it is fixed too. See the bug #1410238 and the fix http://pkgs.fedoraproject.org/cgit/rpms/mongodb.git/commit/?h=epel7&id=ebbb1e6f631804bbb922fc53c513b9bc48c3b2fa I don't suggest fixing this by removing '/bin/kill -USR1' to mongod process. Without this mongodb does not know, that rotation was done. A default behavior is that mongodb adds "start up" information to new log file after rotation (to know more information about which mongod produced new log, configuration,...). First it is upstream behavior. Also it seems useful to me. Pradeep, is this bug reproducible in Fedora?
This issue is already fixed in fedora - for MongoDB 3.0+ by upsteam change, for MongoDB 2.6 in EPEL7 in above mentioned bug #1410238 So closing this bug. Feel free to reopen.