Buggy code:
private CommitLog ( ) { } public void resetUnsafe ( ) { } private boolean manages ( String name ) { } public static int recover ( ) throws IOException { } public static int recover ( File [ ] clogs ) throws IOException { final Set < Table > tablesRecovered = new HashSet < Table > ( ) ; List < Future < ? > > futures = new ArrayList < Future < ? > > ( ) ; byte [ ] bytes = new byte [ 4096 ] ; Map < Integer , AtomicInteger > invalidMutations = new HashMap < Integer , AtomicInteger > ( ) ; final AtomicInteger replayedCount = new AtomicInteger ( ) ; final Map < Integer , ReplayPosition > cfPositions = new HashMap < Integer , ReplayPosition > ( ) ; for ( ColumnFamilyStore cfs : ColumnFamilyStore . all ( ) ) { ReplayPosition rp = ReplayPosition . getReplayPosition ( cfs . getSSTables ( ) ) ; cfPositions . put ( cfs . metadata . cfId , rp ) ; } final ReplayPosition globalPosition = Ordering . from ( comparator ) . min ( cfPositions . values ( ) ) ; for ( final File file : clogs ) { final long segment = CommitLogSegment . idFromFilename ( file . getName ( ) ) ; int bufferSize = ( ( int ) ( Math . min ( Math . max ( file . length ( ) , 1 ) , ( ( 32 * 1024 ) * 1024 ) ) ) ) ; BufferedRandomAccessFile reader = new BufferedRandomAccessFile ( new File ( file . getAbsolutePath ( ) ) , "r" , bufferSize , true ) ; assert ( reader . length ( ) ) <= ( Integer . MAX_VALUE ) ; try { int replayPosition ; if ( ( globalPosition . segment ) < segment ) replayPosition = 0 ; else if ( ( globalPosition . segment ) == segment ) replayPosition = globalPosition . position ; else replayPosition = ( ( int ) ( reader . length ( ) ) ) ; if ( ( replayPosition < 0 ) || ( replayPosition >= ( reader . length ( ) ) ) ) { CommitLog . logger . debug ( "skipping<seq2seq4repair_space>replay<seq2seq4repair_space>of<seq2seq4repair_space>fully-flushed<seq2seq4repair_space>{}" , file ) ; continue ; } reader . seek ( replayPosition ) ; if ( CommitLog . logger . isDebugEnabled ( ) ) CommitLog . logger . debug ( ( ( ( "Replaying<seq2seq4repair_space>" + file ) + "<seq2seq4repair_space>starting<seq2seq4repair_space>at<seq2seq4repair_space>" ) + ( reader . getFilePointer ( ) ) ) ) ; while ( ! ( reader . isEOF ( ) ) ) { if ( CommitLog . logger . isDebugEnabled ( ) ) CommitLog . logger . debug ( ( "Reading<seq2seq4repair_space>mutation<seq2seq4repair_space>at<seq2seq4repair_space>" + ( reader . getFilePointer ( ) ) ) ) ; long claimedCRC32 ; Checksum checksum = new CRC32 ( ) ; int serializedSize ; try { serializedSize = reader . readInt ( ) ; if ( serializedSize < 10 ) break ; long claimedSizeChecksum = reader . readLong ( ) ; checksum . update ( serializedSize ) ; if ( ( checksum . getValue ( ) ) != claimedSizeChecksum ) break ; if ( serializedSize > ( bytes . length ) ) bytes = new byte [ ( ( int ) ( 1.2 * serializedSize ) ) ] ; reader . readFully ( bytes , 0 , serializedSize ) ; claimedCRC32 = reader . readLong ( ) ; } catch ( EOFException eof ) { break ; } checksum . update ( bytes , 0 , serializedSize ) ; if ( claimedCRC32 != ( checksum . getValue ( ) ) ) { continue ; } ByteArrayInputStream bufIn = new ByteArrayInputStream ( bytes , 0 , serializedSize ) ; RowMutation rm = null ; try { <START_BUG> rm = RowMutation . serializer ( ) . deserialize ( new DataInputStream ( bufIn ) , version_ ) ; <END_BUG> } catch ( UnserializableColumnFamilyException ex ) { AtomicInteger i = invalidMutations . get ( ex . cfId ) ; if ( i == null ) { i = new AtomicInteger ( 1 ) ; invalidMutations . put ( ex . cfId , i ) ; } else i . incrementAndGet ( ) ; continue ; } if ( CommitLog . logger . isDebugEnabled ( ) ) CommitLog . logger . debug ( String . format ( "replaying<seq2seq4repair_space>mutation<seq2seq4repair_space>for<seq2seq4repair_space>%s.%s:<seq2seq4repair_space>%s" , rm . getTable ( ) , ByteBufferUtil . bytesToHex ( rm . key ( ) ) , ( ( "{" + ( StringUtils . join ( rm . getColumnFamilies ( ) , ",<seq2seq4repair_space>" ) ) ) + "}" ) ) ) ; final long entryLocation = reader . getFilePointer ( ) ; final RowMutation frm = rm ; Runnable runnable = new WrappedRunnable ( ) { public void runMayThrow ( ) throws IOException { if ( ( DatabaseDescriptor . getKSMetaData ( frm . getTable ( ) ) ) == null ) return ; final Table table = Table . open ( frm . getTable ( ) ) ; RowMutation newRm = new RowMutation ( frm . getTable ( ) , frm . key ( ) ) ; for ( ColumnFamily columnFamily : frm . getColumnFamilies ( ) ) { if ( ( CFMetaData . getCF ( columnFamily . id ( ) ) ) == null ) continue ; ReplayPosition rp = cfPositions . get ( columnFamily . id ( ) ) ; if ( ( segment > ( rp . segment ) ) || ( ( segment == ( rp . segment ) ) && ( entryLocation > ( rp . position ) ) ) ) { newRm . add ( columnFamily ) ; replayedCount . incrementAndGet ( ) ; } } if ( ! ( newRm . isEmpty ( ) ) ) { Table . open ( newRm . getTable ( ) ) . apply ( newRm , false ) ; tablesRecovered . add ( table ) ; } }

Fix:
rm = RowMutation . serializer ( ) . deserialize ( new DataInputStream ( bufIn ) , version_ , false ) ;