Program: 132441
Project: 132441
Buggy source:
/** 
 * <p>Needed for the initial load process of the babuDB, done by the replication.</p>
 * @param latest - {@link LSN} until which the loading is done.
 * @throws BabuDBException 
 */
public void reset(LSN latest) throws BabuDBException {
  for (  LSMDBWorker w : worker) {
    w.shutdown();
  }
  logger.shutdown();
  if (dbCheckptr != null) {
    dbCheckptr.shutdown();
  }
  try {
    logger.waitForShutdown();
    for (    LSMDBWorker w : worker) {
      w.waitForShutdown();
    }
    if (dbCheckptr != null) {
      dbCheckptr.waitForShutdown();
    }
  }
 catch (  InterruptedException ex) {
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  dbNames.clear();
  databases.clear();
  nextDbId=1;
  compInstances.clear();
  compInstances.put(DefaultByteRangeComparator.class.getName(),new DefaultByteRangeComparator());
  loadDBs();
  LSN dbLsn=null;
  for (  LSMDatabase db : databases.values()) {
    if (dbLsn == null)     dbLsn=db.getOndiskLSN();
 else {
      if (!dbLsn.equals(db.getOndiskLSN()))       throw new RuntimeException("String_Node_Str");
    }
  }
  if (dbLsn == null) {
    dbLsn=new LSN(0,0);
  }
 else {
    dbLsn=new LSN(dbLsn.getViewId(),dbLsn.getSequenceNo() + 1);
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  LSN nextLSN=replayLogs();
  Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + latest.toString() + "String_Node_Str"+ dbLsn.toString()+ "String_Node_Str"+ nextLSN.toString());
  if (dbLsn.compareTo(nextLSN) > 0) {
    nextLSN=dbLsn;
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + nextLSN);
  try {
    logger=new DiskLogger(configuration.getDbLogDir(),latest.getViewId(),latest.getSequenceNo() + 1L,configuration.getSyncMode(),configuration.getPseudoSyncWait(),configuration.getMaxQueueLength() * configuration.getNumThreads());
    logger.start();
  }
 catch (  IOException ex) {
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
  }
synchronized (dbModificationLock) {
    dbModificationLock.notifyAll();
  }
synchronized (checkpointLock) {
    checkpointLock.notifyAll();
  }
  overlaySwitchLock=new ReentrantReadWriteLock();
  replicationFacade.changeContextSwitchLock(overlaySwitchLock.readLock());
  worker=new LSMDBWorker[configuration.getNumThreads()];
  for (int i=0; i < configuration.getNumThreads(); i++) {
    worker[i]=new LSMDBWorker(logger,i,overlaySwitchLock,(configuration.getPseudoSyncWait() > 0),configuration.getMaxQueueLength(),replicationFacade);
    worker[i].start();
  }
  if (configuration.getCheckInterval() > 0) {
    dbCheckptr=new Checkpointer(this,logger,configuration.getCheckInterval(),configuration.getMaxLogfileSize());
    dbCheckptr.start();
  }
 else {
    dbCheckptr=null;
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + BABUDB_VERSION + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * <p>Needed for the initial load process of the babuDB, done by the replication.</p>
 * @param latest - {@link LSN} until which the loading is done.
 * @throws BabuDBException 
 */
public void reset(LSN latest) throws BabuDBException {
  for (  LSMDBWorker w : worker) {
    w.shutdown();
  }
  logger.shutdown();
  if (dbCheckptr != null) {
    dbCheckptr.shutdown();
  }
  try {
    logger.waitForShutdown();
    for (    LSMDBWorker w : worker) {
      w.waitForShutdown();
    }
    if (dbCheckptr != null) {
      dbCheckptr.waitForShutdown();
    }
  }
 catch (  InterruptedException ex) {
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  dbNames.clear();
  databases.clear();
  nextDbId=1;
  compInstances.clear();
  compInstances.put(DefaultByteRangeComparator.class.getName(),new DefaultByteRangeComparator());
  loadDBs();
  LSN dbLsn=null;
  for (  LSMDatabase db : databases.values()) {
    if (dbLsn == null)     dbLsn=db.getOndiskLSN();
 else {
      if (!dbLsn.equals(db.getOndiskLSN()))       throw new RuntimeException("String_Node_Str");
    }
  }
  if (dbLsn == null) {
    dbLsn=new LSN(0,0);
  }
 else {
    dbLsn=new LSN(dbLsn.getViewId(),dbLsn.getSequenceNo() + 1);
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  LSN nextLSN=replayLogs();
  if (dbLsn.compareTo(nextLSN) > 0) {
    nextLSN=dbLsn;
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + nextLSN);
  try {
    logger=new DiskLogger(configuration.getDbLogDir(),latest.getViewId(),latest.getSequenceNo() + 1L,configuration.getSyncMode(),configuration.getPseudoSyncWait(),configuration.getMaxQueueLength() * configuration.getNumThreads());
    logger.start();
  }
 catch (  IOException ex) {
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
  }
synchronized (dbModificationLock) {
    dbModificationLock.notifyAll();
  }
synchronized (checkpointLock) {
    checkpointLock.notifyAll();
  }
  overlaySwitchLock=new ReentrantReadWriteLock();
  replicationFacade.changeContextSwitchLock(overlaySwitchLock.readLock());
  worker=new LSMDBWorker[configuration.getNumThreads()];
  for (int i=0; i < configuration.getNumThreads(); i++) {
    worker[i]=new LSMDBWorker(logger,i,overlaySwitchLock,(configuration.getPseudoSyncWait() > 0),configuration.getMaxQueueLength(),replicationFacade);
    worker[i].start();
  }
  if (configuration.getCheckInterval() > 0) {
    dbCheckptr=new Checkpointer(this,logger,configuration.getCheckInterval(),configuration.getMaxLogfileSize());
    dbCheckptr.start();
  }
 else {
    dbCheckptr=null;
  }
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + BABUDB_VERSION + "String_Node_Str");
}