Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.pulsar.compaction;

import static org.apache.pulsar.compaction.Compactor.COMPACTION_SUBSCRIPTION;
import com.github.benmanes.caffeine.cache.AsyncLoadingCache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.common.collect.ComparisonChain;
Expand Down Expand Up @@ -128,8 +127,7 @@ public void asyncReadEntriesOrWait(ManagedCursor cursor,
// need to force seek the read position to ensure the compactor can read
// the complete last snapshot because of the compactor will read the data
// before the compaction cursor mark delete position
cursor.seek(lastEntry.getPosition().getNext(),
cursor.getName().equals(COMPACTION_SUBSCRIPTION));
cursor.seek(lastEntry.getPosition().getNext(), true);
callback.readEntriesComplete(entries, consumer);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,5 +481,20 @@ public void testDoNotLossTheLastCompactedLedgerData() throws Exception {
PersistentTopicInternalStats stats = admin.topics().getInternalStats(topic);
Assert.assertEquals(stats.compactedLedger.entries, keys + 1);
});

// Make sure the reader can get all data from the compacted ledger and original ledger.
Reader<String> reader = pulsarClient.newReader(Schema.STRING)
.topic(topic)
.startMessageId(MessageId.earliest)
.readCompacted(true)
.create();
int received = 0;
while (reader.hasMessageAvailable()) {
reader.readNext();
received++;
}
Assert.assertEquals(received, keys + 1);
reader.close();
producer.close();
}
}