Jean-Baptiste Quenot (JIRA) wrote:
[ http://issues.apache.org/jira/browse/COCOON-1799?page=all ]
Jean-Baptiste Quenot reopened COCOON-1799:
------------------------------------------
I'm reopening this issue just for trunk: AbstractCachingProcessingPipeline
locking feature *must* be ported to trunk, and this bugfix as well.
IMHO given the current code base, the bug has already been fixed
everywhere. The bug was introduced with the newly "locking feature".
Note the bug was only for 2.1.x-dev and since the code has not been
merged in 2.2 yet, actually it does not apply for 2.2. When the trunk
will be synchronized, this bug will be automatically fixed there too,
hence the bug has never been nor will appear in 2.2.
On the other side, if what we wanted to point out was a reminder that
the code needs to be marge for this class in 2.2, I think this bug
report is the worse place to put this kind of reminder. If a reminder is
necesary, then please open a new bug with the correct description:
"Merge 'AbstractCachingProcessingPipeline.java' code from 2.1 in 2.2" or
something like that.
BTW, We committers should merge our changes in branch to trunk to keep
both synchronized. I know this is a boring task, but an important one.
wdyt?
Best Regards,
Antonio Gallardo.
[PATCH] Threads waste when reading a not found resource.
--------------------------------------------------------
Key: COCOON-1799
URL: http://issues.apache.org/jira/browse/COCOON-1799
Project: Cocoon
Type: Bug
Components: * Cocoon Core
Versions: 2.1.9-dev (current SVN)
Reporter: Simone Gianni
Assignee: Antonio Gallardo
Priority: Blocker
Fix For: 2.1.9-dev (current SVN)
Attachments: pipeline.diff
When setting up a pipeline with a reader on a not found file, the first time a
404 is reported, but following requests will hang up and the thread will never
get released, causing a potential complete lock exausting threads.
In the AbstractCachingProcessingPipeline class, in ProcessReader method, the
following happens :
- 774: a pcKey is created for caching content
- 853: the method eventually waits if another thread is generating
- 869: the method acquires a lock, to avoid other threads to generate twice
- 886: if there is no need cache validity pcKey is setted to null
- 918: if an exception occurrs while generating, the following code is in a
finally :
if (pcKey != null) {
releaseLock(pcKey);
}
This obviously brings to the following situation :
- A non existing resource is being generated
- A lock is acquired
- The FileSource returns null if the file does not exist.
- So pcKey is setted to null.
- An exception is thrown, since the file is not found.
- The finally block does not release the lock
- Next requests on the same file will hang waiting on the lock, but the other
thread will never release it.
This can easily consume all threads, it's quite easy to have this kind of errors on a missing gif, or css, or favicon.ico or something else.
I modified this class so that it :
- Does not set pckey to null when readerValidity == null
- Checks for pckey != null && readerValidity != null on line 907 so that
content is not cached if readerValidity == null
- Since pckey is != null the lock is released.
I tested it and seems to work correctly, but this is core stuff, please double
check it!!