Buggy code:
public static final ExecutorService postFlushExecutor = new JMXEnabledThreadPoolExecutor ( "MemtablePostFlusher" ) ; public final Table table ; public final String columnFamily ; public final CFMetaData metadata ; public final IPartitioner partitioner ; private final String mbeanName ; private boolean invalid = false ; private final DataTracker data ; private volatile int memtableSwitchCount = 0 ; private AtomicInteger fileIndexGenerator = new AtomicInteger ( 0 ) ; private final ConcurrentSkipListMap < ByteBuffer , ColumnFamilyStore > indexedColumns ; private AtomicReference < BinaryMemtable > binaryMemtable ; private LatencyTracker readStats = new LatencyTracker ( ) ; private LatencyTracker writeStats = new LatencyTracker ( ) ; private final EstimatedHistogram recentSSTablesPerRead = new EstimatedHistogram ( 35 ) ; private final EstimatedHistogram sstablesPerRead = new EstimatedHistogram ( 35 ) ; private static final int INTERN_CUTOFF = 256 ; public final ConcurrentMap < ByteBuffer , ByteBuffer > internedNames = new org . cliffc . high_scale_lib . NonBlockingHashMap < ByteBuffer , ByteBuffer > ( ) ; private volatile DefaultInteger minCompactionThreshold ; private volatile DefaultInteger maxCompactionThreshold ; private volatile DefaultInteger memtime ; private volatile DefaultInteger memsize ; private volatile DefaultDouble memops ; private volatile DefaultInteger rowCacheSaveInSeconds ; private volatile DefaultInteger keyCacheSaveInSeconds ; public final Lock flushLock = new ReentrantLock ( ) ; public static enum CacheType { KEY_CACHE_TYPE ( "KeyCache" ) , ROW_CACHE_TYPE ( "RowCache" ) ; public final String name ; private CacheType ( String name ) { } @ Override public String toString ( ) { } } public final AutoSavingCache < Pair < Descriptor , DecoratedKey > , Long > keyCache ; public final AutoSavingCache < DecoratedKey , ColumnFamily > rowCache ; volatile double liveRatio = 1.0 ; private final AtomicLong liveRatioComputedAt = new AtomicLong ( 32 ) ; public void reload ( ) { } void removeIndex ( ByteBuffer indexedColumn ) { } private ColumnFamilyStore ( Table table , String columnFamilyName , IPartitioner partitioner , int generation , CFMetaData metadata ) { } public Future < ? > addIndex ( final ColumnDefinition info ) { } public void buildSecondaryIndexes ( Collection < SSTableReader > sstables , SortedSet < ByteBuffer > columns ) { } void unregisterMBean ( ) { } public long getMinRowSize ( ) { } public long getMaxRowSize ( ) { } public long getMeanRowSize ( ) { } public int getMeanColumns ( ) { } public static ColumnFamilyStore createColumnFamilyStore ( Table table , String columnFamily ) { } public static synchronized ColumnFamilyStore createColumnFamilyStore ( Table table , String columnFamily , IPartitioner partitioner , CFMetaData metadata ) { } public static void scrubDataDirectories ( String table , String columnFamily ) { } public void initCaches ( ) { } public void scheduleCacheSaving ( int rowCacheSavePeriodInSeconds , int keyCacheSavePeriodInSeconds ) { } public AutoSavingCache < Pair < Descriptor , DecoratedKey > , Long > getKeyCache ( ) { } private static Map < Descriptor , Set < Component > > files ( String keyspace , final String columnFamily , final boolean includeCompacted ) { } public String getColumnFamilyName ( ) { } public String getFlushPath ( long estimatedSize , String version ) { } public String getTempSSTablePath ( String directory , String version ) { } public String getTempSSTablePath ( String directory ) { } Future < ? > maybeSwitchMemtable ( Memtable oldMemtable , final boolean writeCommitLog ) { if ( oldMemtable . isFrozen ( ) ) { ColumnFamilyStore . logger . debug ( "memtable<seq2seq4repair_space>is<seq2seq4repair_space>already<seq2seq4repair_space>frozen;<seq2seq4repair_space>another<seq2seq4repair_space>thread<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>flushing<seq2seq4repair_space>it" ) ; return null ; } switchLock . writeLock ( ) . lock ( ) ; try { if ( oldMemtable . isFrozen ( ) ) { ColumnFamilyStore . logger . debug ( "memtable<seq2seq4repair_space>is<seq2seq4repair_space>already<seq2seq4repair_space>frozen;<seq2seq4repair_space>another<seq2seq4repair_space>thread<seq2seq4repair_space>must<seq2seq4repair_space>be<seq2seq4repair_space>flushing<seq2seq4repair_space>it" ) ; return null ; } assert ( getMemtableThreadSafe ( ) ) == oldMemtable ; oldMemtable . freeze ( ) ; <START_BUG> final ReplayPosition ctx = ( writeCommitLog ) ? instance . getContext ( ) : null ; <END_BUG> List < ColumnFamilyStore > icc = new ArrayList < ColumnFamilyStore > ( indexedColumns . size ( ) ) ; for ( ColumnFamilyStore cfs : concatWithIndexes ( ) ) { if ( ! ( cfs . getMemtableThreadSafe ( ) . isClean ( ) ) ) icc . add ( cfs ) ; } final CountDownLatch latch = new CountDownLatch ( icc . size ( ) ) ; for ( ColumnFamilyStore cfs : icc ) submitFlush ( cfs . data . switchMemtable ( ) , latch , ctx ) ; if ( ! ( icc . contains ( this ) ) ) data . renewMemtable ( ) ; if ( ( memtableSwitchCount ) == ( Integer . MAX_VALUE ) ) memtableSwitchCount = 0 ; ( memtableSwitchCount ) ++ ; return ColumnFamilyStore . postFlushExecutor . submit ( new WrappedRunnable ( ) { public void runMayThrow ( ) throws IOException , InterruptedException { latch . await ( ) ; if ( writeCommitLog ) { instance . discardCompletedSegments ( metadata . cfId , ctx ) ; } } } ) ; } finally { switchLock . writeLock ( ) . unlock ( ) ; } } public boolean isDropped ( ) { } void switchBinaryMemtable ( DecoratedKey key , ByteBuffer buffer ) { } public void forceFlushIfExpired ( ) { } public Future < ? > forceFlush ( ) { } public void forceBlockingFlush ( ) throws InterruptedException , ExecutionException { } public void forceFlushBinary ( ) { } public void updateRowCache ( DecoratedKey key , ColumnFamily columnFamily ) { } Memtable apply ( DecoratedKey key , ColumnFamily columnFamily ) { } void applyBinary ( DecoratedKey key , ByteBuffer buffer ) { } public static ColumnFamily removeDeletedCF ( ColumnFamily cf , int gcBefore ) { } public static ColumnFamily removeDeleted ( ColumnFamily cf , int gcBefore ) { } private static void removeDeletedColumnsOnly ( ColumnFamily cf , int gcBefore ) { } private static void removeDeletedStandard ( ColumnFamily cf , int gcBefore ) { } private static void removeDeletedSuper ( ColumnFamily cf , int gcBefore ) { } public boolean isKeyInRemainingSSTables ( DecoratedKey key , Set < ? extends SSTable > sstablesToIgnore ) { }

Fix:
final ReplayPosition ctx = ( writeCommitLog ) ? instance . getContext ( ) : ReplayPosition . NONE ;