Filip,

thank you for the response.  

The issue is fairly simple:

At some point in time (t1) the CoyoteAdapter.service (or the
CoyoteAdapter.event) method calls request.isComet().
If the CometEvent has not been closed at (t1), this method returns true
and request and response are not recycled.

At a later point in time (t2), after returning from the call to the
CoyoteAdapter, the Http11AprProcessor.process (or
Http11AprProcessor.event) method checks the comet flag. If the flag is
false at (t2), the processor will be recycled. 

In almost all cases the comet flag is still true at (t2) if
request.isComet() had returned true at (t1).

However, especially in heavy load situations, another thread may be
scheduled between (t1) and (t2) and call event.close() . In such a
situation, the comet falg will be false at (t2) and the processor is
recycled while request and response are not recycled. The processor will
then process the next request with non-recycled request/response
objects.

My quick and dirty fix calls the recycle methods of request and response
whenever the recycle method of the processor is called, regardless if
request and response had been recycled before or not.


It is not that easy to provide a simple example app that produces such a
behaviour reliably.
I can see that it happens in my application which runs an embedded
Tomcat and a whole bunch of additional threads when the system is under
load, but it does not happen in a simple test situation.


Regards,
Matthias




> -----Original Message-----
> From: Filip Hanik - Dev Lists [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, June 13, 2007 8:09 PM
> To: Tomcat Users List
> Subject: Re: Comet: Unsufficiently synchronized recycling decisions
> 
> Reich, Matthias wrote:
> >  Hello,
> >
> > I did not get any response on my post from 2 weeks ago.
> >
> > Even if non-recycling of request/response objects happens only
> > sporadically and only in webapps where asynchronous 
> responses may happen
> > before the event processing has finished, it is definitively a bug.
> >
> > Should I report it as a bug to receive any reaction?
> >   
> a bug would help only if it has an example app, or enough 
> info to help 
> us truly understand the issue.
> personally, I haven't had enough time to look through it to truly 
> understand it, cause I believe the fix would probably be 
> easier than the 
> one described below
> 
> Filip
> 
> > Regards,
> > Matthias
> >
> >   
> >> -----Original Message-----
> >> From: Reich, Matthias 
> >> Sent: Wednesday, May 30, 2007 2:04 PM
> >> To: 'Tomcat Users List'
> >> Subject: Comet: Unsufficiently synchronized recycling decisions
> >>
> >> Hi,
> >>
> >> as mentioned in my contribution to topic 'Web application 
> >> receives request parameters sent to another application on 
> >> Tomcat 6', I sometimes get non-recycled Request objects in a 
> >> BEGIN event. 
> >>
> >> A non-recycled request object appeared in a BEGIN event if 
> >> the previous request processed by the same request processor 
> >> was answered asynchronously directly after the BEGIN event.
> >>
> >> In such a situation my Servlet sometimes did not get an END 
> >> event, i.e. the CoyoteAdapter was not triggered again and 
> >> therefore could not recycle the Request object.
> >> Nevertheless, the request processor was recycled, i.e. 
> >> readded to the processor pool.
> >>
> >> As the processor was recycled, the cometEvent.close() must 
> >> have happened *after* CoyoteAdapter had made the decision not 
> >> to recycle Request/Response, but *before* Http11AprProtocol 
> >> had made the decision to recycle the processor.
> >>
> >> To verify this, I modified the methods 
> >> Http11AprProcessor.event and Http11AprProcessor.process.
> >>
> >> I replaced every occurrence of:
> >>
> >>   recycle();
> >>
> >> within these methods with the following lines:
> >>
> >>   org.apache.catalina.connector.Request req = 
> >> (org.apache.catalina.connector.Request) request.getNote(1);
> >>   org.apache.catalina.connector.Response res = 
> >> (org.apache.catalina.connector.Response) response.getNote(1);
> >>   req.recycle( );
> >>   res.recycle( );
> >>   recycle();
> >>
> >> I know that this is a hack and must be solved in a better way 
> >> (and also for the NIOConnector), but with these modifications 
> >> I enforced a single decision point for recycling of 
> >> Request/Response *and* the processor.
> >>
> >> When running Tomcat with these modifications, my Servlet no 
> >> longer received non-recycled Request objects.
> >>
> >>
> >> Regards,
> >> Matthias
> >>
> >>     
> >
> > 
> ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >   
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to