[SERVER-45605] Ensure that the first log line written in a log file opened in append mode is on its own line Created: 16/Jan/20  Updated: 29/Oct/23  Resolved: 19/Mar/20

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

Type: New Feature Priority: Major - P3
Reporter: Sara Williamson Assignee: Henrik Edin
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
Backport Requested:
v4.4
Sprint: Dev Tools 2020-03-23
Participants:

 Comments   
Comment by Githook User [ 26/Mar/20 ]

Author:

{'name': 'Henrik Edin', 'username': 'henrikedin', 'email': 'henrik.edin@mongodb.com'}

Message: SERVER-45605 Write newline when opening existing log file in append mode.

This should ensure that the first line written is always parsable.

(cherry picked from commit 6f454fc655dddf3486c4e551004fbb9becb4cb4d)
Branch: v4.4
https://github.com/mongodb/mongo/commit/9fe9de3a8c4b612d53fcb9fa370da2f8c33bbc9d

Comment by Githook User [ 19/Mar/20 ]

Author:

{'email': 'henrik.edin@mongodb.com', 'name': 'Henrik Edin', 'username': 'henrikedin'}

Message: SERVER-45605 Write newline when opening existing log file in append mode.

This should ensure that the first line written is always parsable.
Branch: master
https://github.com/mongodb/mongo/commit/6f454fc655dddf3486c4e551004fbb9becb4cb4d

Comment by Bruce Lucas (Inactive) [ 19/Mar/20 ]

I think any parser needs to be able to gracefully handle malformed lines, and also to ignore empty lines. When this situation arises the last line of the previous instance will probably be malformed so this change won't fix that, but it will ensure that the first line isn't swallowed by that malformed line. The extra newline also would have a slight benefit of making it easier to spot on manual inspection that a restart has occurred. So I see this change as beneficial.

Comment by Henrik Edin [ 19/Mar/20 ]

bruce.lucas Are you interested in this? The implementation would probably be to always write a new line when opening in append mode. So if nothing is wrong you'd have an empty line and the parser need to handle that.

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