Buggy code:
private void switchLogFile ( ) throws StandardException { } private void flushBuffer ( long fileNumber , long wherePosition ) throws IOException , StandardException { } private void truncateLog ( CheckpointOperation checkpoint ) { } private long getFirstLogNeeded ( CheckpointOperation checkpoint ) { } boolean writeControlFile ( StorageFile logControlFileName , long value ) throws IOException , StandardException { } private long readControlFile ( StorageFile logControlFileName , Properties startParams ) throws IOException , StandardException { } private void createLogDirectory ( ) throws StandardException { } public StorageFile getLogDirectory ( ) throws StandardException { } public String getCanonicalLogPath ( ) { } private StorageFile getControlFileName ( ) throws StandardException { } private StorageFile getMirrorControlFileName ( ) throws StandardException { } private StorageFile getLogFileName ( long filenumber ) throws StandardException { } private CheckpointOperation findCheckpoint ( long checkpointInstant , FileLogger logger ) throws IOException , ClassNotFoundException , StandardException { } protected LogScan openBackwardsScan ( long startAt , LogInstant stopAt ) throws IOException , StandardException { } protected LogScan openBackwardsScan ( LogInstant stopAt ) throws IOException , StandardException { } public ScanHandle openFlushedScan ( DatabaseInstant start , int groupsIWant ) throws StandardException { } protected LogScan openForwardsScan ( long startAt , LogInstant stopAt ) throws IOException , StandardException { } protected StorageRandomAccessFile getLogFileAtBeginning ( long filenumber ) throws IOException , StandardException { } protected StorageRandomAccessFile getLogFileAtPosition ( long logInstant ) throws IOException , StandardException { } public boolean canSupport ( Properties startParams ) { } public void boot ( boolean create , Properties startParams ) throws StandardException { dataDirectory = startParams . getProperty ( ROOT ) ; logDevice = startParams . getProperty ( LOG_DEVICE ) ; if ( ( logDevice ) != null ) { String logDeviceURL = null ; try { URL url = new URL ( logDevice ) ; logDeviceURL = url . getFile ( ) ; } catch ( MalformedURLException ex ) { } if ( logDeviceURL != null ) logDevice = logDeviceURL ; } if ( create ) { getLogStorageFactory ( ) ; createLogDirectory ( ) ; } else { if ( ! ( restoreLogs ( startParams ) ) ) { getLogStorageFactory ( ) ; if ( ( logDevice ) != null ) { StorageFile checklogDir = logStorageFactory . newStorageFile ( LOG_DIRECTORY_NAME ) ; if ( ! ( privExists ( checklogDir ) ) ) { throw StandardException . newException ( LOG_FILE_NOT_FOUND , checklogDir . getPath ( ) ) ; } } } } logBufferSize = PropertyUtil . getSystemInt ( org . apache . derby . iapi . reference . Property , LogToFile . LOG_BUFFER_SIZE_MIN , LogToFile . LOG_BUFFER_SIZE_MAX , LogToFile . DEFAULT_LOG_BUFFER_SIZE ) ; jbmsVersion = Monitor . getMonitor ( ) . getEngineVersion ( ) ; String logArchiveMode = startParams . getProperty ( LOG_ARCHIVE_MODE ) ; logArchived = Boolean . valueOf ( logArchiveMode ) . booleanValue ( ) ; getLogFactoryProperties ( null ) ; if ( logStorageFactory . supportsRws ( ) ) { isWriteSynced = ! ( PropertyUtil . getSystemBoolean ( FILESYNC_TRANSACTION_LOG ) ) ; } else { isWriteSynced = false ; } if ( DURABILITY_TESTMODE_NO_SYNC . equalsIgnoreCase ( PropertyUtil . getSystemProperty ( DURABILITY_PROPERTY ) ) ) { logNotSynced = true ; isWriteSynced = false ; } else if ( Performance . MEASURE ) { logNotSynced = PropertyUtil . getSystemBoolean ( STORAGE_LOG_NOT_SYNCED ) ; if ( logNotSynced ) { isWriteSynced = false ; Monitor . logMessage ( "Performance.logNotSynced<seq2seq4repair_space>=<seq2seq4repair_space>true" ) ; } } boolean createNewLog = create ; if ( SanityManager . DEBUG ) SanityManager . ASSERT ( ( ( LogToFile . fid ) != ( - 1 ) ) , "invalid<seq2seq4repair_space>log<seq2seq4repair_space>format<seq2seq4repair_space>Id" ) ; checkpointInstant = LogCounter . INVALID_LOG_INSTANT ; try { StorageFile logControlFileName = getControlFileName ( ) ; StorageFile logFile ; if ( ! createNewLog ) { if ( privExists ( logControlFileName ) ) { checkpointInstant = readControlFile ( logControlFileName , startParams ) ; if ( LogToFile . wasDBInDurabilityTestModeNoSync ) { Monitor . logMessage ( MessageService . getTextMessage ( LOG_WAS_IN_DURABILITY_TESTMODE_NO_SYNC , DURABILITY_PROPERTY , DURABILITY_TESTMODE_NO_SYNC ) ) ; } <START_BUG> if ( ( ( checkpointInstant ) == ( LogCounter . INVALID_LOG_INSTANT ) ) && ( getMirrorControlFileName ( ) . exists ( ) ) ) { <END_BUG> checkpointInstant = readControlFile ( getMirrorControlFileName ( ) , startParams ) ; } } else if ( ( logDevice ) != null ) { throw StandardException . newException ( LOG_FILE_NOT_FOUND , logControlFileName . getPath ( ) ) ; } if ( ( checkpointInstant ) != ( LogCounter . INVALID_LOG_INSTANT ) ) logFileNumber = LogCounter . getLogFileNumber ( checkpointInstant ) ; else logFileNumber = 1 ; logFile = getLogFileName ( logFileNumber ) ; if ( ! ( privExists ( logFile ) ) ) { if ( ( logDevice ) != null ) { throw StandardException . newException ( LOG_FILE_NOT_FOUND , logControlFileName . getPath ( ) ) ; } logErrMsg ( MessageService . getTextMessage ( LOG_MAYBE_INCONSISTENT , logFile . getPath ( ) ) ) ; createNewLog = true ; } else if ( ! ( verifyLogFormat ( logFile , logFileNumber ) ) ) { Monitor . logTextMessage ( LOG_DELETE_INCOMPATIBLE_FILE , logFile ) ; if ( ( ! ( privDelete ( logFile ) ) ) && ( ( logFileNumber ) == 1 ) ) { logErrMsgForDurabilityTestModeNoSync ( ) ; throw StandardException . newException ( LOG_INCOMPATIBLE_FORMAT , dataDirectory ) ; } createNewLog = true ; } } if ( createNewLog ) { if ( writeControlFile ( logControlFileName , INVALID_LOG_INSTANT ) ) { firstLogFileNumber = 1 ; logFileNumber = 1 ; if ( SanityManager . DEBUG ) { if ( SanityManager . DEBUG_ON ( LogToFile . TEST_MAX_LOGFILE_NUMBER ) ) { firstLogFileNumber = ( LogCounter . MAX_LOGFILE_NUMBER ) - 2 ; logFileNumber = ( LogCounter . MAX_LOGFILE_NUMBER ) - 2 ; } } logFile = getLogFileName ( logFileNumber ) ; if ( privExists ( logFile ) ) { Monitor . logTextMessage ( LOG_DELETE_OLD_FILE , logFile ) ; if ( ! ( privDelete ( logFile ) ) ) { logErrMsgForDurabilityTestModeNoSync ( ) ; throw StandardException . newException ( LOG_INCOMPATIBLE_FORMAT , dataDirectory ) ; } }

Fix:
if ( ( ( checkpointInstant ) == ( LogCounter . INVALID_LOG_INSTANT ) ) && ( privExists ( getMirrorControlFileName ( ) ) ) ) {