Re: concurrency problem with #include as template

"Eric B. Ridge" <[email protected]> Sat, 4 Feb 2006 16:32:34 -0500
Newsgroups gmane.comp.java.webmacro.user
Message-ID <[email protected]>
My theory is that SimpleCacheManager.java is broken (http:// 
cvs.sourceforge.net/viewcvs.py/webmacro/webmacro/src/org/webmacro/ 
resource/SimpleCacheManager.java?rev=1.2&view=markup)

It seems the get(query, helper) function would allow concurrent  
readers to load and put the same resource in the _cache at the same  
time.  Obviously, in the end we'd only have one entry in the map, but  
we'd be loading the template twice.

But I don't see how this explains getting the *wrong* template back.   
I would think that concurrent.jar's ConcurrentHashMap would have to  
be broken in order for this to happen.

Just a theory tho.  I've never run across this myself.  Maybe Brian  
can chime in?

Also, a note to Carl.  I realize your wmtest.jar file is designed to  
expose this bug, but if your real code is creating new WM instances  
for *every* thread, you should consider not doing that.  Instead,  
keep one global WM instance.  Just make sure to give each thread  
their own Context object via _wm.getContext().  When WM is working  
properly, a separate Context per thread is all that's needed to  
guarantee thread-safety.

eric

On Feb 4, 2006, at 4:09 PM, Marc Palmer wrote:

>
> On 4 Feb 2006, at 18:56, Carl H. Sayres wrote:
>
>> Hello,
>>
>> We've encountered a concurrency problem with the #include as  
>> template directive. It appears that when multiple threads of  
>> execution are running, webmacro can intermittently select a  
>> different template than the one requested. We have created a test  
>> program that demonstrates the problem. If anyone can provide  
>> insight into the cause of the problem, (or even better, a fix), we  
>> would be very appreciative.
>
> Thanks for this Carl. I haven't had time to run the test but I've  
> looked at the source of it.
>
> It definitely looks like you've found some obscure problem, but  
> it's possible it is either in the include mechanism, template cache  
> implementation, or the introspection code.
>
> Anybody got time to look at this?
>
> cheers
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through  
> log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD  
> SPLUNK!
> http://sel.as-us.falkag.net/sel? 
> cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Webmacro-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/webmacro-user



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642