[ 
https://issues.apache.org/jira/browse/LOG4J2-1235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15153918#comment-15153918
 ] 

Sascha Scholz commented on LOG4J2-1235:
---------------------------------------

I think the solution needs to be different. The problem with setting the future 
to null is that check for calling scheduleNext in update() wouldn't work any 
more reliably: It could happen that future would be set to null in scheduleNext 
after it had been checked in update(). Then the purge task wouldn't run if no 
additional call to update() happens afterwards.

I assume that synchronizing the access to future on every update() call is not 
an option for performance reasons. And double-checked locking of future only 
works if it is never set to null again. So, I think the only option would be to 
re-schedule the purge task with interval=timeToLive. Of course, this could 
cause much load if timeToLive is small. To mitigate this, a checkInterval 
option could be introduced. With that, appenders won't be closed after 
timeToLive, but only with the next check after timeToLive expired.

BTW, is there a check somewhere that timeToLive is >0?

> org.apache.logging.log4j.core.appender.routing.IdlePurgePolicy not working 
> correctly
> ------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1235
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1235
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.5
>            Reporter: Niranjan Rao
>            Priority: Critical
>
> There is a problem in the function 
> org.apache.logging.log4j.core.appender.routing.IdlePurgePolicy.scheduleNext().
> I got out of file handles errors despite of setting IdlePurgePolicy. I did 
> some digging I believe following is the cause
> If the createTime is Long.MAX_VALUE, task is never scheduled. However 
> function 
> org.apache.logging.log4j.core.appender.routing.IdlePurgePolicy.update(String, 
> LogEvent) checks if the future is not null before deciding to schedule.
> After appendersUsage becomes empty first time, appenders keep piling up.
> I believe fix will be to set future to null in the function scheduleNext in 
> the else part of the condition where it checks for createTime



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to