Program: 7847
Project: 7847
Buggy source:
@Test public void testSingleFifo() throws Exception {
  QueueName queueName=QueueName.fromFlowlet("String_Node_Str","String_Node_Str","String_Node_Str");
  final HBaseQueueClient queueClient=new HBaseQueueClient(HBaseTestBase.getHBaseAdmin(),"String_Node_Str",queueName);
  final int count=5000;
  LOG.info("String_Node_Str",count);
  Stopwatch stopwatch=new Stopwatch();
  stopwatch.start();
  for (int i=0; i < count; i++) {
    Transaction transaction=opex.start();
    try {
      byte[] queueData=Bytes.toBytes(i);
      queueClient.startTx(transaction);
      queueClient.enqueue(new QueueEntry(queueData));
      if (opex.canCommit(transaction,queueClient.getTxChanges()) && queueClient.commitTx()) {
        if (!opex.commit(transaction)) {
          queueClient.rollbackTx();
        }
      }
    }
 catch (    Exception e) {
      opex.abort(transaction);
      throw Throwables.propagate(e);
    }
  }
  long elapsed=stopwatch.elapsedTime(TimeUnit.MILLISECONDS);
  LOG.info("String_Node_Str",count,elapsed);
  LOG.info("String_Node_Str",(double)count * 1000 / elapsed);
  final int expectedSum=(count / 2 * (count - 1));
  final AtomicInteger valueSum=new AtomicInteger();
  final int consumerSize=5;
  final CyclicBarrier startBarrier=new CyclicBarrier(consumerSize + 1);
  final CountDownLatch completeLatch=new CountDownLatch(consumerSize);
  ExecutorService executor=Executors.newFixedThreadPool(consumerSize);
  for (int i=0; i < consumerSize; i++) {
    final int instanceId=i;
    executor.submit(new Runnable(){
      @Override public void run(){
        try {
          startBarrier.await();
          QueueConsumer consumer=queueClient.createConsumer(new ConsumerConfig(0,instanceId,consumerSize,DequeueStrategy.FIFO,null));
          TransactionAware txAware=(TransactionAware)consumer;
          Stopwatch stopwatch=new Stopwatch();
          stopwatch.start();
          int dequeueCount=0;
          while (valueSum.get() != expectedSum) {
            Transaction transaction=opex.start();
            txAware.startTx(transaction);
            try {
              DequeueResult result=consumer.dequeue();
              if (opex.canCommit(transaction,queueClient.getTxChanges()) && txAware.commitTx()) {
                if (!opex.commit(transaction)) {
                  txAware.rollbackTx();
                }
              }
              if (result.isEmpty()) {
                continue;
              }
              byte[] data=result.getData().iterator().next();
              valueSum.addAndGet(Bytes.toInt(data));
              dequeueCount++;
            }
 catch (            Exception e) {
              opex.abort(transaction);
              throw Throwables.propagate(e);
            }
          }
          long elapsed=stopwatch.elapsedTime(TimeUnit.MILLISECONDS);
          LOG.info("String_Node_Str",dequeueCount,elapsed);
          LOG.info("String_Node_Str",(double)dequeueCount * 1000 / elapsed);
          completeLatch.countDown();
        }
 catch (        Exception e) {
          LOG.error(e.getMessage(),e);
        }
      }
    }
);
  }
  startBarrier.await();
  Assert.assertTrue(completeLatch.await(40,TimeUnit.SECONDS));
  TimeUnit.SECONDS.sleep(2);
  Assert.assertEquals(expectedSum,valueSum.get());
  executor.shutdownNow();
}

Fixed version (ground truth):
@Test public void testSingleFifo() throws Exception {
  QueueName queueName=QueueName.fromFlowlet("String_Node_Str","String_Node_Str","String_Node_Str");
  final HBaseQueueClient queueClient=new HBaseQueueClient(HBaseTestBase.getHBaseAdmin(),"String_Node_Str",queueName);
  final int count=5000;
  LOG.info("String_Node_Str",count);
  Stopwatch stopwatch=new Stopwatch();
  stopwatch.start();
  for (int i=0; i < count; i++) {
    Transaction transaction=opex.start();
    try {
      byte[] queueData=Bytes.toBytes(i);
      queueClient.startTx(transaction);
      queueClient.enqueue(new QueueEntry(queueData));
      if (opex.canCommit(transaction,queueClient.getTxChanges()) && queueClient.commitTx()) {
        if (!opex.commit(transaction)) {
          queueClient.rollbackTx();
        }
      }
    }
 catch (    Exception e) {
      opex.abort(transaction);
      throw Throwables.propagate(e);
    }
  }
  long elapsed=stopwatch.elapsedTime(TimeUnit.MILLISECONDS);
  LOG.info("String_Node_Str",count,elapsed);
  LOG.info("String_Node_Str",(double)count * 1000 / elapsed);
  final int expectedSum=(count / 2 * (count - 1));
  final AtomicInteger valueSum=new AtomicInteger();
  final int consumerSize=3;
  final CyclicBarrier startBarrier=new CyclicBarrier(consumerSize + 1);
  final CountDownLatch completeLatch=new CountDownLatch(consumerSize);
  ExecutorService executor=Executors.newFixedThreadPool(consumerSize);
  for (int i=0; i < consumerSize; i++) {
    final int instanceId=i;
    executor.submit(new Runnable(){
      @Override public void run(){
        try {
          startBarrier.await();
          QueueConsumer consumer=queueClient.createConsumer(new ConsumerConfig(0,instanceId,consumerSize,DequeueStrategy.FIFO,null));
          TransactionAware txAware=(TransactionAware)consumer;
          Stopwatch stopwatch=new Stopwatch();
          stopwatch.start();
          int dequeueCount=0;
          while (valueSum.get() != expectedSum) {
            Transaction transaction=opex.start();
            txAware.startTx(transaction);
            try {
              DequeueResult result=consumer.dequeue();
              if (opex.canCommit(transaction,queueClient.getTxChanges()) && txAware.commitTx()) {
                if (!opex.commit(transaction)) {
                  txAware.rollbackTx();
                }
              }
              if (result.isEmpty()) {
                continue;
              }
              for (              byte[] data : result.getData()) {
                valueSum.addAndGet(Bytes.toInt(data));
                dequeueCount++;
              }
            }
 catch (            Exception e) {
              opex.abort(transaction);
              throw Throwables.propagate(e);
            }
          }
          long elapsed=stopwatch.elapsedTime(TimeUnit.MILLISECONDS);
          LOG.info("String_Node_Str",dequeueCount,elapsed);
          LOG.info("String_Node_Str",(double)dequeueCount * 1000 / elapsed);
          completeLatch.countDown();
        }
 catch (        Exception e) {
          LOG.error(e.getMessage(),e);
        }
      }
    }
);
  }
  startBarrier.await();
  Assert.assertTrue(completeLatch.await(120,TimeUnit.SECONDS));
  TimeUnit.SECONDS.sleep(2);
  Assert.assertEquals(expectedSum,valueSum.get());
  executor.shutdownNow();
}