[logback-dev] [JIRA] Commented: (LBCORE-183) race condition when creating log directory in multithreaded environment
Ralph Goers (JIRA)
noreply-jira at qos.ch
Wed Dec 8 02:25:51 CET 2010
[ http://jira.qos.ch/browse/LBCORE-183?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11911#action_11911 ]
Ralph Goers commented on LBCORE-183:
------------------------------------
Not that your patch is bad, but your description has to be incorrect. FileAppender.openFile() synchronizes on a lock so there is no way you can have a race from the same appender calling createMissingParentDirectories. From what I can see, the only way this can occur is if two different appenders are creating files in the same directory.
> race condition when creating log directory in multithreaded environment
> -----------------------------------------------------------------------
>
> Key: LBCORE-183
> URL: http://jira.qos.ch/browse/LBCORE-183
> Project: logback-core
> Issue Type: Bug
> Components: Other
> Affects Versions: 0.9.26
> Reporter: Mats Henrikson
> Assignee: Logback dev list
> Attachments: parent_dirs.patch
>
>
> There is a race condition when multiple threads are trying to create the same parent log directory in logback:
> {noformat}
> java.lang.IllegalStateException: /path/to/log/dir/2010/2010_12/2010_12_08/file.log should not have existing parent directory
> at ch.qos.logback.core.util.FileUtil.createMissingParentDirectories(FileUtil.java:43) ~[logback-core-0.9.26.jar:na]
> at ch.qos.logback.core.FileAppender.openFile(FileAppender.java:156) ~[logback-core-0.9.26.jar:na]
> at ch.qos.logback.core.FileAppender.start(FileAppender.java:115) ~[logback-core-0.9.26.jar:na]
> [...]
> {noformat}
> It is completely ok for the check to start if the directory is there and then have the directory appear when we actually come around to creating it. This is because you may have multiple threads wanting to log to the same directory, and if they try to create the dir at the same time one will succeed and one will have it already created. This happens for instance in the case above where a new dir is created at midnight every day, and two threads log at the same time.
> Will attach a patch that fixes the problem.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the logback-dev
mailing list