Program: 132342
Project: 132342
Buggy source:
/** 
 * <p> Needed for the initial load process of the babuDB, done by the replication. </p>
 * @throws BabuDBException
 * @return the next LSN.
 */
public LSN restart() throws BabuDBException {
synchronized (stopped) {
    if (!stopped.get())     throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str");
    databaseManager.reset();
    dbCheckptr=new CheckpointerImpl(this);
    LSN dbLsn=null;
    LSN zero=new LSN(0,0L);
    for (    Database dbRaw : databaseManager.getDatabaseList()) {
      DatabaseImpl db=(DatabaseImpl)dbRaw;
      LSN onDisk=db.getLSMDB().getOndiskLSN();
      if (dbLsn == null && !onDisk.equals(zero))       dbLsn=onDisk;
 else       if (dbLsn != null) {
        if (!onDisk.equals(zero) && !dbLsn.equals(onDisk))         throw new RuntimeException("String_Node_Str" + dbLsn.toString() + "String_Node_Str"+ db.getLSMDB().getOndiskLSN().toString());
      }
    }
    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(dbLsn);
    if (dbLsn.compareTo(nextLSN) > 0)     nextLSN=dbLsn;
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + nextLSN);
    try {
      logger=new DiskLogger(configuration.getDbLogDir(),nextLSN.getViewId(),nextLSN.getSequenceNo(),configuration.getSyncMode(),configuration.getPseudoSyncWait(),configuration.getMaxQueueLength() * configuration.getNumThreads(),replicationManager);
      logger.start();
    }
 catch (    IOException ex) {
      throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
    }
    if (configuration.getNumThreads() > 0) {
      worker=new LSMDBWorker[configuration.getNumThreads()];
      for (int i=0; i < configuration.getNumThreads(); i++) {
        worker[i]=new LSMDBWorker(logger,i,(configuration.getPseudoSyncWait() > 0),configuration.getMaxQueueLength());
        worker[i].start();
      }
    }
 else {
      assert(configuration.getNumThreads() == 0);
      worker=null;
    }
    dbCheckptr.init(logger,configuration.getCheckInterval(),configuration.getMaxLogfileSize());
    dbCheckptr.start();
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + "String_Node_Str" + BABUDB_VERSION + "String_Node_Str");
    this.stopped.set(false);
    return new LSN(nextLSN.getViewId(),nextLSN.getSequenceNo() - 1L);
  }
}

Fixed version (ground truth):
/** 
 * <p> Needed for the initial load process of the babuDB, done by the replication. </p>
 * @throws BabuDBException
 * @return the next LSN.
 */
public LSN restart() throws BabuDBException {
synchronized (stopped) {
    if (!stopped.get())     throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str");
    databaseManager.reset();
    dbCheckptr=new CheckpointerImpl(this);
    LSN dbLsn=null;
    for (    Database db : databaseManager.getDatabaseList()) {
      if (dbLsn == null)       dbLsn=((DatabaseImpl)db).getLSMDB().getOndiskLSN();
 else {
        LSN onDiskLSN=((DatabaseImpl)db).getLSMDB().getOndiskLSN();
        if (!(LSMDatabase.NO_DB_LSN.equals(dbLsn) || LSMDatabase.NO_DB_LSN.equals(onDiskLSN)))         dbLsn=dbLsn.compareTo(onDiskLSN) < 0 ? dbLsn : onDiskLSN;
      }
    }
    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(dbLsn);
    if (dbLsn.compareTo(nextLSN) > 0)     nextLSN=dbLsn;
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + nextLSN);
    try {
      logger=new DiskLogger(configuration.getDbLogDir(),nextLSN.getViewId(),nextLSN.getSequenceNo(),configuration.getSyncMode(),configuration.getPseudoSyncWait(),configuration.getMaxQueueLength() * configuration.getNumThreads(),replicationManager);
      logger.start();
    }
 catch (    IOException ex) {
      throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",ex);
    }
    if (configuration.getNumThreads() > 0) {
      worker=new LSMDBWorker[configuration.getNumThreads()];
      for (int i=0; i < configuration.getNumThreads(); i++) {
        worker[i]=new LSMDBWorker(logger,i,(configuration.getPseudoSyncWait() > 0),configuration.getMaxQueueLength());
        worker[i].start();
      }
    }
 else {
      assert(configuration.getNumThreads() == 0);
      worker=null;
    }
    dbCheckptr.init(logger,configuration.getCheckInterval(),configuration.getMaxLogfileSize());
    dbCheckptr.start();
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + "String_Node_Str" + BABUDB_VERSION + "String_Node_Str");
    this.stopped.set(false);
    return new LSN(nextLSN.getViewId(),nextLSN.getSequenceNo() - 1L);
  }
}