[logback-dev] [JIRA] Commented: (LBCORE-97) Starvation on AppenderBase.doAppend

Robert Elliot rob at lidalia.org.uk
Sun May 31 19:21:35 CEST 2009


On 31 May 2009, at 17:51, Robert Elliot wrote:

> Just as an academic question, what do you think of an architecture  
> where the various debug/info/error etc. calls on Logger all put  
> something like a LoggingEvent (though probably an immutable  
> equivalent) on a blocking queue, and a single thread takes events  
> off the top of the queue and calls the appenders with it?
>
> Then appender calls would be done in a single threaded way, and so  
> an appender implementation would not need to worry about thread  
> safety.
...
> Would the problem Joern is experiencing with multiple threads  
> competing for a lock and only one of them getting the lock still  
> occur?

I think I can answer my own question at the end there - yes, it might  
see the same problem if the bounded queue were full and there were  
multiple threads blocked waiting to log an event - you could see one  
thread go round and round and round being the only one adding to the  
queue while all the others sit there, if it were back waiting to log  
again before the consumer thread had managed to take another event off  
the top of the queue.  But ArrayBlockingQueue can be made fair via a  
constructor parameter, in which case once the queue is full threads  
will get to add to it in the order they started waiting to do so and  
so the problem goes away.


More information about the logback-dev mailing list