34
34
import org .elasticsearch .cluster .routing .IndexShardRoutingTable ;
35
35
import org .elasticsearch .cluster .routing .ShardRouting ;
36
36
import org .elasticsearch .cluster .service .ClusterService ;
37
- import org .elasticsearch .common .Nullable ;
38
- import org .elasticsearch .common .Strings ;
39
37
import org .elasticsearch .common .UUIDs ;
40
38
import org .elasticsearch .common .component .AbstractComponent ;
41
39
import org .elasticsearch .common .inject .Inject ;
67
65
import java .io .IOException ;
68
66
import java .util .ArrayList ;
69
67
import java .util .Collections ;
70
- import java .util .HashMap ;
71
68
import java .util .List ;
72
69
import java .util .Map ;
73
70
import java .util .concurrent .ConcurrentMap ;
@@ -219,16 +216,9 @@ public void onResponse(InFlightOpsResponse response) {
219
216
if (inflight != 0 ) {
220
217
actionListener .onResponse (new ShardsSyncedFlushResult (shardId , totalShards , "[" + inflight + "] ongoing operations on primary" ));
221
218
} else {
222
- // 3. now send the sync request to all the shards;
223
- final String sharedSyncId = sharedExistingSyncId (presyncResponses );
224
- if (sharedSyncId != null ) {
225
- assert presyncResponses .values ().stream ().allMatch (r -> r .existingSyncId .equals (sharedSyncId )) :
226
- "Not all shards have the same existing sync id [" + sharedSyncId + "], responses [" + presyncResponses + "]" ;
227
- reportSuccessWithExistingSyncId (shardId , sharedSyncId , activeShards , totalShards , presyncResponses , actionListener );
228
- }else {
229
- String syncId = UUIDs .base64UUID ();
230
- sendSyncRequests (syncId , activeShards , state , presyncResponses , shardId , totalShards , actionListener );
231
- }
219
+ // 3. now send the sync request to all the shards
220
+ String syncId = UUIDs .base64UUID ();
221
+ sendSyncRequests (syncId , activeShards , state , presyncResponses , shardId , totalShards , actionListener );
232
222
}
233
223
}
234
224
@@ -254,33 +244,6 @@ public void onFailure(Exception e) {
254
244
}
255
245
}
256
246
257
- private String sharedExistingSyncId (Map <String , PreSyncedFlushResponse > preSyncedFlushResponses ) {
258
- String existingSyncId = null ;
259
- for (PreSyncedFlushResponse resp : preSyncedFlushResponses .values ()) {
260
- if (Strings .isNullOrEmpty (resp .existingSyncId )) {
261
- return null ;
262
- }
263
- if (existingSyncId == null ) {
264
- existingSyncId = resp .existingSyncId ;
265
- }
266
- if (existingSyncId .equals (resp .existingSyncId ) == false ) {
267
- return null ;
268
- }
269
- }
270
- return existingSyncId ;
271
- }
272
-
273
- private void reportSuccessWithExistingSyncId (ShardId shardId , String existingSyncId , List <ShardRouting > shards , int totalShards ,
274
- Map <String , PreSyncedFlushResponse > preSyncResponses , ActionListener <ShardsSyncedFlushResult > listener ) {
275
- final Map <ShardRouting , ShardSyncedFlushResponse > results = new HashMap <>();
276
- for (final ShardRouting shard : shards ) {
277
- if (preSyncResponses .containsKey (shard .currentNodeId ())) {
278
- results .put (shard , new ShardSyncedFlushResponse ());
279
- }
280
- }
281
- listener .onResponse (new ShardsSyncedFlushResult (shardId , existingSyncId , totalShards , results ));
282
- }
283
-
284
247
final IndexShardRoutingTable getShardRoutingTable (ShardId shardId , ClusterState state ) {
285
248
final IndexRoutingTable indexRoutingTable = state .routingTable ().index (shardId .getIndexName ());
286
249
if (indexRoutingTable == null ) {
@@ -475,7 +438,7 @@ private PreSyncedFlushResponse performPreSyncedFlush(PreShardSyncedFlushRequest
475
438
final CommitStats commitStats = indexShard .commitStats ();
476
439
final Engine .CommitId commitId = commitStats .getRawCommitId ();
477
440
logger .trace ("{} pre sync flush done. commit id {}, num docs {}" , request .shardId (), commitId , commitStats .getNumDocs ());
478
- return new PreSyncedFlushResponse (commitId , commitStats .getNumDocs (), commitStats . syncId () );
441
+ return new PreSyncedFlushResponse (commitId , commitStats .getNumDocs ());
479
442
}
480
443
481
444
private ShardSyncedFlushResponse performSyncedFlush (ShardSyncedFlushRequest request ) {
@@ -547,19 +510,24 @@ public ShardId shardId() {
547
510
static final class PreSyncedFlushResponse extends TransportResponse {
548
511
static final int UNKNOWN_NUM_DOCS = -1 ;
549
512
public static final int V_6_2_2_ID = 6020299 ;
550
- public static final int V_6_3_0_ID = 6030099 ;
551
513
552
514
Engine .CommitId commitId ;
553
515
int numDocs ;
554
- @ Nullable String existingSyncId = null ;
555
516
556
517
PreSyncedFlushResponse () {
557
518
}
558
519
559
- PreSyncedFlushResponse (Engine .CommitId commitId , int numDocs , String existingSyncId ) {
520
+ PreSyncedFlushResponse (Engine .CommitId commitId , int numDocs ) {
560
521
this .commitId = commitId ;
561
522
this .numDocs = numDocs ;
562
- this .existingSyncId = existingSyncId ;
523
+ }
524
+
525
+ Engine .CommitId commitId () {
526
+ return commitId ;
527
+ }
528
+
529
+ int numDocs () {
530
+ return numDocs ;
563
531
}
564
532
565
533
boolean includeNumDocs (Version version ) {
@@ -570,14 +538,6 @@ boolean includeNumDocs(Version version) {
570
538
}
571
539
}
572
540
573
- boolean includeExistingSyncId (Version version ) {
574
- if (version .major == Version .V_5_6_9_UNRELEASED .major ) {
575
- return version .onOrAfter (Version .V_5_6_9_UNRELEASED );
576
- } else {
577
- return version .id >= V_6_3_0_ID ;
578
- }
579
- }
580
-
581
541
@ Override
582
542
public void readFrom (StreamInput in ) throws IOException {
583
543
super .readFrom (in );
@@ -587,9 +547,6 @@ public void readFrom(StreamInput in) throws IOException {
587
547
} else {
588
548
numDocs = UNKNOWN_NUM_DOCS ;
589
549
}
590
- if (includeExistingSyncId (in .getVersion ())) {
591
- existingSyncId = in .readOptionalString ();
592
- }
593
550
}
594
551
595
552
@ Override
@@ -599,9 +556,6 @@ public void writeTo(StreamOutput out) throws IOException {
599
556
if (includeNumDocs (out .getVersion ())) {
600
557
out .writeInt (numDocs );
601
558
}
602
- if (includeExistingSyncId (out .getVersion ())) {
603
- out .writeOptionalString (existingSyncId );
604
- }
605
559
}
606
560
}
607
561
0 commit comments