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 @@ -2493,6 +2493,7 @@ public void testConcurrentWritesAndCommits() throws Exception {
prevLocalCheckpoint = localCheckpoint;
prevMaxSeqNo = maxSeqNo;
}
IOUtils.close(commits);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void testRetentionLeasesSyncedOnAdd() throws Exception {

// check retention leases have been committed on the primary
final RetentionLeases primaryCommittedRetentionLeases = RetentionLeases.decodeRetentionLeases(
primary.acquireLastIndexCommit(false).getIndexCommit().getUserData().get(Engine.RETENTION_LEASES));
primary.commitStats().getUserData().get(Engine.RETENTION_LEASES));
assertThat(currentRetentionLeases, equalTo(RetentionLeases.toMap(primaryCommittedRetentionLeases)));

// check current retention leases have been synced to all replicas
Expand All @@ -120,7 +120,7 @@ public void testRetentionLeasesSyncedOnAdd() throws Exception {

// check retention leases have been committed on the replica
final RetentionLeases replicaCommittedRetentionLeases = RetentionLeases.decodeRetentionLeases(
replica.acquireLastIndexCommit(false).getIndexCommit().getUserData().get(Engine.RETENTION_LEASES));
replica.commitStats().getUserData().get(Engine.RETENTION_LEASES));
assertThat(currentRetentionLeases, equalTo(RetentionLeases.toMap(replicaCommittedRetentionLeases)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import org.elasticsearch.index.engine.CommitStats;
import org.elasticsearch.index.engine.DocIdSeqNoAndTerm;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.engine.EngineTestCase;
import org.elasticsearch.index.engine.InternalEngine;
import org.elasticsearch.index.seqno.SeqNoStats;
import org.elasticsearch.index.seqno.SequenceNumbers;
Expand Down Expand Up @@ -1254,6 +1255,7 @@ public void beforeIndexDeletion() throws Exception {
//check that shards that have same sync id also contain same number of documents
assertSameSyncIdSameDocs();
assertOpenTranslogReferences();
assertNoSnapshottedIndexCommit();
}

private void assertSameSyncIdSameDocs() {
Expand Down Expand Up @@ -1324,6 +1326,28 @@ private void assertOpenTranslogReferences() throws Exception {
});
}

private void assertNoSnapshottedIndexCommit() throws Exception {
assertBusy(() -> {
final Collection<NodeAndClient> nodesAndClients = nodes.values();
for (NodeAndClient nodeAndClient : nodesAndClients) {
IndicesService indexServices = getInstance(IndicesService.class, nodeAndClient.name);
for (IndexService indexService : indexServices) {
for (IndexShard indexShard : indexService) {
try {
Engine engine = IndexShardTestCase.getEngine(indexShard);
if (engine instanceof InternalEngine) {
assertFalse(indexShard.routingEntry().toString() + " has unreleased snapshotted index commits",
EngineTestCase.hasSnapshottedCommits(engine));
}
} catch (AlreadyClosedException ignored) {

}
}
}
}
});
}

/**
* Asserts that the document history in Lucene index is consistent with Translog's on every index shard of the cluster.
* This assertion might be expensive, thus we prefer not to execute on every test but only interesting tests.
Expand Down