[
https://issues.apache.org/jira/browse/LOG4J2-2106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16248918#comment-16248918
]
Ralph Goers commented on LOG4J2-2106:
-------------------------------------
That is a good question. Both rollover and checkRollover synchronize on the
FileManager. So all calls to checkRollover are synchronized and will be blocked
by rollover. rollover calls rollover(strategy). It waits for any async tasks to
be completed before it will execute (to prevent trying to compress the same
file). This will cause a second call to rollover to block until all async
threads are complete, which will cause threads to block waiting to log.
The logic in rollover(strategy) of waiting for the async thread to complete is
correct and is required. But I don't believe logging should be blocked while
the rollover completes. So this may only partially solve the reporter's issue.
*Potential Issue 1*
I made isTriggeringEvent in both TimeBasedTriggeringPolicy and
SizeBasedTriggeringPolicy synchronized. However, both update the file time so
both need to use the same lock. I will need to create a lock for them to
synchronize on.
*Potential Issue 2*
That is really the same as Potential Issue 1 and the same fix should apply.
*Optimization*
I don't think that will work as the call to getNextTime needs to be locked
against changes by calls to updateTime from SizeBasedTriggeringPolicy. That
could be done by synchronizing those methods.
But I now see another issue. It seems that we allow the patternProcessor to be
replaced on a reconfiguration. Currently it copies the time values from the old
pattern processor to the new one. But that only works properly if the pattern
processor time values cannot be changed after the new copy is made or only use
the new PatternProcessor after the values are copied. Right now updateData
isn't synchronized at all.
> May blocked when two compress action
> ------------------------------------
>
> Key: LOG4J2-2106
> URL: https://issues.apache.org/jira/browse/LOG4J2-2106
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.9.1
> Reporter: skopt
>
> My log file is very large, so I set the config about compression. The
> policies is as follows:
> <Policies>
> <OnStartupTriggeringPolicy/>
> <TimeBasedTriggeringPolicy/>
> </Policies>
> When restart the service on the hour, this will trigger the two
> policies. And I find that the log can not be written for a while.
> I think, there would be two compress actions. In the file
> RollingFileManager(package org.apache.logging.log4j.core.appender.rolling),
> the actions will submit to asyncExecutor which will create a new thread for
> every work. That mean the log file will be compressed by the two actions. Is
> this the cause?
> Thanks.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)