History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CACHE-128
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Lars Torunski
Reporter: Simone Avogadro
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
OSCache

Multiple matching filters will dead-lock the response

Created: 12/Jan/05 06:03 AM   Updated: 06/Nov/05 11:20 AM
Component/s: Filters
Affects Version/s: 2.0.2
Fix Version/s: 2.2 RC

Environment: tested and debugged with JDK 1.4.2 and Resin 2.1.12


 Description  « Hide
when using the filter you might want to cache multiple patterns.
e.g.:
pattern1: /upload/*
pattern2: *.gif

in such a configuration requesting a resource like /upload/test.gif will cause a deed-lock

here is why:
- pattern1 is invoked
- pattern1 holds a monitor telling it's going to cache the resource
- pattern1 tells the filter-chain to produce the content
- pattern2 is invoked
- pattern2 finds the object already being cached
- pattern2 being wait on the monitor
- a dead-lock is born

basically the monitor should avoid quick-flooding by placing multiple parallel requests in a queue, however in this case both the callers come from the same request and thus should now block eachother

 All   Comments   Change History      Sort Order:
Andres March - [14/Jan/05 07:24 PM ]
Would you like to submit a patch?

Simone Avogadro - [17/Jan/05 03:15 AM ]
sorry, I couldn't came up with a patch for this. Currently I take care to avoid such situations :-(

Lars Torunski - [28/Jan/05 05:34 PM ]
Maybe implementation:
1. check if a special request attribute "__OSCACHE_FILTERED" exists
2. if true then only invoke chain.doFilter(request, response);
3. if false then set the special request attribute and then run the existing code

Lars Torunski - [30/Jan/05 02:39 AM ]
1.
Add new boolean parameter "OncePerRequest" to the ServletFilter configuration part in web.xml. The default value is "false", so backwards compatibility isn't broken.

2.
Document parameter in http://wiki.opensymphony.com/display/CACHE/CacheFilter

Simone Avogadro - [11/Feb/05 08:41 AM ]
I don't think that the default should be 'false' for the flag. Even in old applications I can't see any reason to continue generating deadlocks.
The only problem could be with request attribute name conflict with existing attributes, which il really unlike if you choose a very specific name (e.g.: "_oscache_filter_multipass_once").

Lars Torunski - [11/Feb/05 05:36 PM ]
If nobody will comment an use case for calling CacheFilter more than once in a request here, we havn't to provide a OncePerRequest parameter. Instead CacheFilter will be called only once per request always.

Lars Torunski - [16/Feb/05 03:53 PM ]
Since nobody added a use case (set oncePerRequest to false), the filter will be performed only once per request.