-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log rotation feature crashes intermittently #768
Comments
Moved here: winstonjs/winston-daily-rotate-file#9 |
Why was this moved? I'm not using that transport. I'm using features in core winston. |
Id love to get a reproducible case of this if you can take a stab at it @nikdunn |
Copied from: #800. One of the tickets should be cancelled. The problem seems to be a result of the self._archive variable being set to '/work/server/server.log' when the code enters the compressFile() function. See the code here: https://github.com/winstonjs/winston/blob/master/lib/winston/transports/file.js#L468-L530 Usually, when the code executes: So winston opens a new file for writing new log data ('/work/server/server.log') and opens a read stream ('/work/server/server1.log') that gets piped through gzip and to a write stream ('/work/server/server1.log.gz'). I believe the crash occurs when '/work/server/server.log' sneaks through into the compressFile() function. I think the sequence is:
That's my current theory anyway. My question is: should winston ever gzip '/work/server/server.log'? Is this for the non-tailable log rotation case? Am I on the right track? Okay fine that was three questions. |
Follow up... The problem is caused by two different maxsize tests conflicting with one another. This line: https://github.com/winstonjs/winston/blob/master/lib/winston/transports/file.js#L371 tests maxsize against (I'm guessing) the number of bytes theoretically written to the file, but not necessarily written to the file. This causes _createStream() to be called. This test: https://github.com/winstonjs/winston/blob/master/lib/winston/transports/file.js#L540 tests the actual file size of the log file. I've seen the first test pass, and the second test fail. In that event, createAndFlush() gets called, but _incFile() does not. So createAndFlush attempts to create 'server.log' and reads from it to create 'server.log.gz' |
I have this too:
|
Should've I created this file manually or what? |
Maybe there's some racing condition when creating a file? |
This is fixed. Here is the pull request. #828 |
Closing this based on #828 but if problems persist in the latest versions of winston (3.1.0 or |
I have no idea if it is related to the other crash issues I've seen documented, but I am seeing:
Error: ENOENT, open '/work/server/server.log'
Every once in a while. In the directory there is a server.log.gz that is 0 bytes along with other log files that have been successfully rotated.
The issue seems to happen when logging frequency and content is high.
I've handled the uncaught exception, but there's not really anything I can do about it since the logger blew chunks.
I'm doing:
The text was updated successfully, but these errors were encountered: