[SERVER-49320] No error message produced if log file can't be created Created: 05/Jul/20  Updated: 29/Oct/23  Resolved: 22/Jul/20

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: 4.4.0-rc11
Fix Version/s: 4.7.0, 4.4.2

Type: Bug Priority: Major - P3
Reporter: Bruce Lucas (Inactive) Assignee: Gabriel Russell (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4
Participants:

 Description   

In 4.2 if you specify a log file that can't be created an error message is written to stderr before mongod exits:

> mongod --dbpath /tmp --logpath /nonexistent/directory
2020-07-05T09:51:55.287-0400 F  CONTROL  [main] Failed global initialization: FileNotOpen: Failed to open "/nonexistent/directory"

In 4.4 mongod just silently exits, giving the user no clue what the problem is.



 Comments   
Comment by Githook User [ 05/Oct/20 ]

Author:

{'name': 'Gabriel Russell', 'email': 'gabriel.russell@mongodb.com', 'username': 'gabrielrussell'}

Message: SERVER-49320 only unconfigure the console when logging is fully configured
Branch: v4.4
https://github.com/mongodb/mongo/commit/ebb91ab3c74151232dc04dd45be44a3f6d6c103d

Comment by Gabriel Russell (Inactive) [ 22/Jul/20 ]

The problem was that we disabled the console logger before trying to configure the file logger, but if the file logger configuration failed then we were left with no logger. I just switched the order of disabling the console logger and enabling the file logger and the error log was no longer lost.

While I was in there, I made the additional change of making the failure of configuring the file logger clearer. The only thing that let someone know that we were looking at a log configuration error was the path itself, and if the path was unknown or ambiguous, then it wasn't possible to know what was actually failing. The error log will know look like so:

{"t":{"$date":"2020-07-22T17:40:42.282Z"},"s":"F",  "c":"CONTROL",  "id":20574,   "ctx":"main","msg":"Error during global initialization","attr":{"error":{"code":38,"codeName":"FileNotOpen","errmsg":"Can't initialize rotatable log file :: caused by :: Failed to open /nonexistent/directory"}}}

Comment by Githook User [ 22/Jul/20 ]

Author:

{'name': 'Gabriel Russell', 'email': 'gabriel.russell@mongodb.com', 'username': 'gabrielrussell'}

Message: SERVER-49320 better errmor message when unable to open rotatable log file
Branch: master
https://github.com/mongodb/mongo/commit/afaab6e52000eb9c38fb5de094f02a79c8897266

Comment by Githook User [ 21/Jul/20 ]

Author:

{'name': 'Gabriel Russell', 'email': 'gabriel.russell@mongodb.com', 'username': 'gabrielrussell'}

Message: SERVER-49320 only unconfigure the console when logging is fully configured
Branch: master
https://github.com/mongodb/mongo/commit/11545c03ed7294b114613dfb168bc6bc42e99fe3

Generated at Thu Feb 08 05:19:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.