Program: 5031
Project: 5031
Buggy source:
@Test public void testOldGenCleanup() throws Exception {
  try (MetadataTable metadataTable=getMetadataTable();MessageTable messageTable=getMessageTable();PayloadTable payloadTable=getPayloadTable()){
    int txWritePtr=100;
    TopicId topicId=NamespaceId.DEFAULT.topic("String_Node_Str");
    TopicMetadata topic=new TopicMetadata(topicId,TopicMetadata.TTL_KEY,"String_Node_Str",TopicMetadata.GENERATION_KEY,Integer.toString(GENERATION));
    metadataTable.createTopic(topic);
    List<MessageTable.Entry> entries=new ArrayList<>();
    List<PayloadTable.Entry> pentries=new ArrayList<>();
    byte[] messageId=new byte[MessageId.RAW_ID_SIZE];
    MessageId.putRawId(0L,(short)0,0L,(short)0,messageId,0);
    entries.add(new TestMessageEntry(topicId,GENERATION,"String_Node_Str",txWritePtr,(short)0));
    pentries.add(new TestPayloadEntry(topicId,GENERATION,"String_Node_Str",txWritePtr,(short)0));
    messageTable.store(entries.iterator());
    payloadTable.store(pentries.iterator());
    try (CloseableIterator<MessageTable.Entry> iterator=messageTable.fetch(topic,0,Integer.MAX_VALUE,null)){
      checkMessageEntry(iterator,txWritePtr);
    }
     try (CloseableIterator<PayloadTable.Entry> iterator=payloadTable.fetch(topic,txWritePtr,new MessageId(messageId),true,100)){
      checkPayloadEntry(iterator,txWritePtr);
    }
     forceFlushAndCompact(Table.MESSAGE);
    forceFlushAndCompact(Table.PAYLOAD);
    try (CloseableIterator<MessageTable.Entry> iterator=messageTable.fetch(topic,0,Integer.MAX_VALUE,null)){
      checkMessageEntry(iterator,txWritePtr);
    }
     try (CloseableIterator<PayloadTable.Entry> iterator=payloadTable.fetch(topic,txWritePtr,new MessageId(messageId),true,100)){
      checkPayloadEntry(iterator,txWritePtr);
    }
     metadataTable.deleteTopic(topicId);
    TimeUnit.SECONDS.sleep(1);
    forceFlushAndCompact(Table.MESSAGE);
    forceFlushAndCompact(Table.PAYLOAD);
    try (CloseableIterator<MessageTable.Entry> iterator=messageTable.fetch(topic,0,Integer.MAX_VALUE,null)){
      Assert.assertFalse(iterator.hasNext());
    }
     try (CloseableIterator<PayloadTable.Entry> iterator=payloadTable.fetch(topic,txWritePtr,new MessageId(messageId),true,100)){
      Assert.assertFalse(iterator.hasNext());
    }
   }
 }

Fixed version (ground truth):
@Test public void testOldGenCleanup() throws Exception {
  try (MetadataTable metadataTable=getMetadataTable();MessageTable messageTable=getMessageTable();PayloadTable payloadTable=getPayloadTable()){
    int txWritePtr=100;
    TopicId topicId=NamespaceId.DEFAULT.topic("String_Node_Str");
    TopicMetadata topic=new TopicMetadata(topicId,TopicMetadata.TTL_KEY,"String_Node_Str",TopicMetadata.GENERATION_KEY,Integer.toString(GENERATION));
    metadataTable.createTopic(topic);
    List<MessageTable.Entry> entries=new ArrayList<>();
    List<PayloadTable.Entry> pentries=new ArrayList<>();
    byte[] messageId=new byte[MessageId.RAW_ID_SIZE];
    MessageId.putRawId(0L,(short)0,0L,(short)0,messageId,0);
    entries.add(new TestMessageEntry(topicId,GENERATION,"String_Node_Str",txWritePtr,(short)0));
    pentries.add(new TestPayloadEntry(topicId,GENERATION,"String_Node_Str",txWritePtr,(short)0));
    messageTable.store(entries.iterator());
    payloadTable.store(pentries.iterator());
    try (CloseableIterator<MessageTable.Entry> iterator=messageTable.fetch(topic,0,Integer.MAX_VALUE,null)){
      checkMessageEntry(iterator,txWritePtr);
    }
     try (CloseableIterator<PayloadTable.Entry> iterator=payloadTable.fetch(topic,txWritePtr,new MessageId(messageId),true,100)){
      checkPayloadEntry(iterator,txWritePtr);
    }
     forceFlushAndCompact(Table.MESSAGE);
    forceFlushAndCompact(Table.PAYLOAD);
    try (CloseableIterator<MessageTable.Entry> iterator=messageTable.fetch(topic,0,Integer.MAX_VALUE,null)){
      checkMessageEntry(iterator,txWritePtr);
    }
     try (CloseableIterator<PayloadTable.Entry> iterator=payloadTable.fetch(topic,txWritePtr,new MessageId(messageId),true,100)){
      checkPayloadEntry(iterator,txWritePtr);
    }
     metadataTable.deleteTopic(topicId);
    TimeUnit.SECONDS.sleep(3);
    forceFlushAndCompact(Table.MESSAGE);
    forceFlushAndCompact(Table.PAYLOAD);
    try (CloseableIterator<MessageTable.Entry> iterator=messageTable.fetch(topic,0,Integer.MAX_VALUE,null)){
      Assert.assertFalse(iterator.hasNext());
    }
     try (CloseableIterator<PayloadTable.Entry> iterator=payloadTable.fetch(topic,txWritePtr,new MessageId(messageId),true,100)){
      Assert.assertFalse(iterator.hasNext());
    }
   }
 }