kpm1985 commented on issue #1000: CuratorFramework and IntegrationTest 
Exceptions
URL: https://github.com/apache/fluo/issues/1000#issuecomment-358899764
 
 
   @mikewalch @keith-turner @ctubbsii 
   
   There are a few issues I've identified that are legitimate concerns. For the 
sake of this please attention to synchronization. Learning how to do line 
inserts, not sure how. Apologies. 
   
         synchronized (this) {
           byte[] d = curatorFramework.getData().forPath(maxTsPath);
           currentTs = maxTs = LongUtil.fromByteArray(d);
         }
   
   Notice the synchronization on these objects from takeLeadership()  
**above**: non synchronized method with a synchronized block
   
     private synchronized long getTimestampsImpl(String id, int num) throws 
TException {
   
   Consider this method, it is synchronized above, 
   
           allocateTimestamp();
   
   This line is not synchronized. Follow code into this method:
   
       long newMax = Long.parseLong(new String(d)) + 1000;
   
   
       
curatorFramework.setData().withVersion(stat.getVersion()).forPath(maxTsPath,
           LongUtil.toByteArray(newMax));
       maxTs = newMax;
   
   Notice there is no synchronization on these. Object monitors and locks to do 
not inherit. This is made clear at this line earlier in the code, inside a 
synchronized method: 
   
       // do this outside of sync
       stampsHistogram.update(num);
   
   I've profiled the code over the last week, this is a race condition that is 
leading to a lot of non-deterministic build errors and failures.  isLeader is 
another volatile variable that is never locked on causing race conditions and 
exceptions.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to