From c4f9a41581474fb44d9d9f25fc7384d44db86576 Mon Sep 17 00:00:00 2001 From: Britta Weber Date: Mon, 18 May 2015 10:41:13 +0200 Subject: [PATCH] more comments and formatting --- .../java/org/elasticsearch/indices/SyncedFlushService.java | 3 +++ .../elasticsearch/indices/recovery/RecoverySourceHandler.java | 2 +- src/test/java/org/elasticsearch/test/InternalTestCluster.java | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/elasticsearch/indices/SyncedFlushService.java b/src/main/java/org/elasticsearch/indices/SyncedFlushService.java index eafbc72f8c5..6678b1c89dc 100644 --- a/src/main/java/org/elasticsearch/indices/SyncedFlushService.java +++ b/src/main/java/org/elasticsearch/indices/SyncedFlushService.java @@ -127,6 +127,9 @@ public class SyncedFlushService extends AbstractComponent { * changes on the replica (the write operation has not reached the replica yet). * * Step 2 detects this scenario and fails the whole synced flush if a write operation is ongoing on the primary. + * Together with the conditions for step 3 (same commit id and no uncommitted changes) this guarantees that a snc id will only + * be written on a primary if no write operation was executed between step 1 and step 3 and sync id will only be written on + * the replica if it contains the same changes that the primary contains. * * Synced flush is a best effort operation. The sync id may be written on all, some or none of the copies. * diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java b/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java index 93b6e5f030b..b9dd72aa72b 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java @@ -415,7 +415,7 @@ public class RecoverySourceHandler { // related to this recovery (out of date segments, for example) // are deleted try { - final Store.MetadataSnapshot remainingFilesAfterCleanup = recoverWithSyncId? request.metadataSnapshot(): recoverySourceMetadata; + final Store.MetadataSnapshot remainingFilesAfterCleanup = recoverWithSyncId ? request.metadataSnapshot() : recoverySourceMetadata; transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.CLEAN_FILES, new RecoveryCleanFilesRequest(request.recoveryId(), shard.shardId(), remainingFilesAfterCleanup, translogView.totalOperations()), TransportRequestOptions.options().withTimeout(recoverySettings.internalActionTimeout()), diff --git a/src/test/java/org/elasticsearch/test/InternalTestCluster.java b/src/test/java/org/elasticsearch/test/InternalTestCluster.java index 505c9f49d48..c3436544b31 100644 --- a/src/test/java/org/elasticsearch/test/InternalTestCluster.java +++ b/src/test/java/org/elasticsearch/test/InternalTestCluster.java @@ -977,6 +977,8 @@ public final class InternalTestCluster extends TestCluster { // and not all docs have been purged after the test) and inherit from // ElasticsearchIntegrationTest must override beforeIndexDeletion() to avoid failures. assertShardIndexCounter(); + //check that shards that have same sync id also contain same number of documents + } private void assertShardIndexCounter() {