You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by Sean Timm <ti...@aol.com> on 2008/04/09 21:35:10 UTC

RequestHandlerBase statistics atomicity problem?

> public abstract class RequestHandlerBase implements 
> SolrRequestHandler, SolrInfoMBean {
>
>   // statistics
>   // TODO: should we bother synchronizing these, or is an off-by-one error
>   // acceptable every million requests or so?
>   long numRequests;
>   long numErrors;
Shouldn't numRequests and numErrors be volatile variables?  Writes are 
not atomic on longs unless they are volatile.

-Sean

Re: RequestHandlerBase statistics atomicity problem?

Posted by Chris Hostetter <ho...@fucit.org>.
I'm not an expert on JVM atomicity, but i believe you are correct ... 
would you mind opening a bug and submitting a patch?

(i wonder if there are are there any other longs where we have the same problem)

: > public abstract class RequestHandlerBase implements SolrRequestHandler,
: > SolrInfoMBean {
: > 
: >   // statistics
: >   // TODO: should we bother synchronizing these, or is an off-by-one error
: >   // acceptable every million requests or so?
: >   long numRequests;
: >   long numErrors;
: Shouldn't numRequests and numErrors be volatile variables?  Writes are not
: atomic on longs unless they are volatile.
: 
: -Sean




-Hoss