Skip to content

Commit 6ec0ef6

Browse files
committed
Merge branch 'master' into replica-sequence-number-recovery
* master: [TEST] Fixed the incorrect indentation for the `skip` clauses in the REST tests Fix primary relocation for shadow replicas (#22474)
2 parents d360a23 + 4f4b76c commit 6ec0ef6

File tree

12 files changed

+57
-50
lines changed

12 files changed

+57
-50
lines changed

core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public RecoveryResponse recoverToTarget() throws IOException {
156156
}
157157

158158
try {
159-
prepareTargetForTranslog(translogView.totalOperations());
159+
prepareTargetForTranslog(translogView.totalOperations(), shard.segmentStats(false).getMaxUnsafeAutoIdTimestamp());
160160
} catch (final Exception e) {
161161
throw new RecoveryEngineException(shard.shardId(), 1, "prepare target for translog failed", e);
162162
}
@@ -377,14 +377,13 @@ public void phase1(final IndexCommit snapshot, final Translog.View translogView)
377377
}
378378
}
379379

380-
void prepareTargetForTranslog(final int totalTranslogOps) throws IOException {
380+
void prepareTargetForTranslog(final int totalTranslogOps, final long maxUnsafeAutoIdTimestamp) throws IOException {
381381
StopWatch stopWatch = new StopWatch().start();
382382
logger.trace("{} recovery [phase1] to {}: prepare remote engine for translog", request.shardId(), request.targetNode());
383383
final long startEngineStart = stopWatch.totalTime().millis();
384384
// Send a request preparing the new shard's translog to receive operations. This ensures the shard engine is started and disables
385385
// garbage collection (not the JVM's GC!) of tombstone deletes.
386-
cancellableThreads.executeIO(
387-
() -> recoveryTarget.prepareForTranslogOperations(totalTranslogOps, shard.segmentStats(false).getMaxUnsafeAutoIdTimestamp()));
386+
cancellableThreads.executeIO(() -> recoveryTarget.prepareForTranslogOperations(totalTranslogOps, maxUnsafeAutoIdTimestamp));
388387
stopWatch.stop();
389388

390389
response.startTime = stopWatch.totalTime().millis() - startEngineStart;

core/src/main/java/org/elasticsearch/indices/recovery/SharedFSRecoverySourceHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public RecoveryResponse recoverToTarget() throws IOException {
5050
boolean engineClosed = false;
5151
try {
5252
logger.trace("{} recovery [phase1] to {}: skipping phase1 for shared filesystem", request.shardId(), request.targetNode());
53+
final long maxUnsafeAutoIdTimestamp = shard.segmentStats(false).getMaxUnsafeAutoIdTimestamp();
5354
if (request.isPrimaryRelocation()) {
5455
logger.debug("[phase1] closing engine on primary for shared filesystem recovery");
5556
try {
@@ -62,7 +63,7 @@ public RecoveryResponse recoverToTarget() throws IOException {
6263
shard.failShard("failed to close engine (phase1)", e);
6364
}
6465
}
65-
prepareTargetForTranslog(0);
66+
prepareTargetForTranslog(0, maxUnsafeAutoIdTimestamp);
6667
finalizeRecovery();
6768
return response;
6869
} catch (Exception e) {

core/src/test/java/org/elasticsearch/index/IndexWithShadowReplicasIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ public void testPrimaryRelocation() throws Exception {
362362
client().admin().indices().prepareUpdateSettings(IDX).setSettings(build).execute().actionGet();
363363

364364
ensureGreen(IDX);
365+
// check if primary has relocated to node3
366+
assertEquals(internalCluster().clusterService(node3).localNode().getId(),
367+
client().admin().cluster().prepareState().get().getState().routingTable().index(IDX).shard(0).primaryShard().currentNodeId());
365368
logger.info("--> performing query");
366369
SearchResponse resp = client().prepareSearch(IDX).setQuery(matchAllQuery()).get();
367370
assertHitCount(resp, 2);

core/src/test/java/org/elasticsearch/indices/recovery/RecoverySourceHandlerTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.elasticsearch.common.settings.ClusterSettings;
4242
import org.elasticsearch.common.settings.Settings;
4343
import org.elasticsearch.index.IndexSettings;
44+
import org.elasticsearch.index.engine.SegmentsStats;
4445
import org.elasticsearch.index.seqno.SeqNoStats;
4546
import org.elasticsearch.index.seqno.SequenceNumbersService;
4647
import org.elasticsearch.index.shard.IndexShard;
@@ -69,6 +70,7 @@
6970
import static java.util.Collections.emptySet;
7071
import static org.hamcrest.Matchers.equalTo;
7172
import static org.mockito.Matchers.any;
73+
import static org.mockito.Matchers.anyBoolean;
7274
import static org.mockito.Mockito.doAnswer;
7375
import static org.mockito.Mockito.mock;
7476
import static org.mockito.Mockito.when;
@@ -284,6 +286,7 @@ public void testThrowExceptionOnPrimaryRelocatedBeforePhase1Completed() throws I
284286
attemptSequenceNumberBasedRecovery ? randomNonNegativeLong() : SequenceNumbersService.UNASSIGNED_SEQ_NO);
285287
final IndexShard shard = mock(IndexShard.class);
286288
when(shard.seqNoStats()).thenReturn(mock(SeqNoStats.class));
289+
when(shard.segmentStats(anyBoolean())).thenReturn(mock(SegmentsStats.class));
287290
final Translog.View translogView = mock(Translog.View.class);
288291
when(shard.acquireTranslogView()).thenReturn(translogView);
289292
when(shard.state()).thenReturn(IndexShardState.RELOCATED);
@@ -301,7 +304,7 @@ public void testThrowExceptionOnPrimaryRelocatedBeforePhase1Completed() throws I
301304
logger) {
302305

303306
@Override
304-
boolean isTranslogReadyForSequenceNumberBasedRecovery(Translog.View translogView) {
307+
boolean isTranslogReadyForSequenceNumberBasedRecovery(final Translog.View translogView) {
305308
return isTranslogReadyForSequenceNumberBasedRecovery;
306309
}
307310

@@ -311,7 +314,7 @@ public void phase1(final IndexCommit snapshot, final Translog.View translogView)
311314
}
312315

313316
@Override
314-
void prepareTargetForTranslog(int totalTranslogOps) throws IOException {
317+
void prepareTargetForTranslog(final int totalTranslogOps, final long maxUnsafeAutoIdTimestamp) throws IOException {
315318
prepareTargetForTranslogCalled.set(true);
316319
}
317320

@@ -350,6 +353,7 @@ public void testWaitForClusterStateOnPrimaryRelocation() throws IOException, Int
350353

351354
final IndexShard shard = mock(IndexShard.class);
352355
when(shard.seqNoStats()).thenReturn(mock(SeqNoStats.class));
356+
when(shard.segmentStats(anyBoolean())).thenReturn(mock(SegmentsStats.class));
353357
final Translog.View translogView = mock(Translog.View.class);
354358
when(shard.acquireTranslogView()).thenReturn(translogView);
355359
when(shard.state()).then(i -> relocated.get() ? IndexShardState.RELOCATED : IndexShardState.STARTED);
@@ -400,7 +404,7 @@ public void phase1(final IndexCommit snapshot, final Translog.View translogView)
400404
}
401405

402406
@Override
403-
void prepareTargetForTranslog(final int totalTranslogOps) throws IOException {
407+
void prepareTargetForTranslog(final int totalTranslogOps, final long maxUnsafeAutoIdTimestamp) throws IOException {
404408
prepareTargetForTranslogCalled.set(true);
405409
}
406410

rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
---
6262
"Test cat nodes output with full_id set":
6363
- skip:
64-
version: " - 5.0.0"
65-
reason: The full_id setting was rejected in 5.0.0 see #21266
64+
version: " - 5.0.0"
65+
reason: The full_id setting was rejected in 5.0.0 see #21266
6666

6767

6868
- do:

rest-api-spec/src/main/resources/rest-api-spec/test/field_stats/10_basics.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ setup:
164164
---
165165
"Geopoint field stats with level set to indices":
166166
- skip:
167-
version: " - 5.2.0"
168-
reason: geo_point fields don't return min/max for versions greater than 5.2.0
167+
version: " - 5.2.0"
168+
reason: geo_point fields don't return min/max for versions greater than 5.2.0
169169

170170
- do:
171171
field_stats:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_template/10_basic.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ setup:
1212
"Get template":
1313

1414
- skip:
15-
version: " - 5.99.99"
16-
reason: this uses a new API that has been added in 6.0
15+
version: " - 5.99.99"
16+
reason: this uses a new API that has been added in 6.0
1717

1818
- do:
1919
indices.get_template:
@@ -26,8 +26,8 @@ setup:
2626
"Get all templates":
2727

2828
- skip:
29-
version: " - 5.99.99"
30-
reason: this uses a new API that has been added in 6.0
29+
version: " - 5.99.99"
30+
reason: this uses a new API that has been added in 6.0
3131

3232
- do:
3333
indices.put_template:
@@ -47,8 +47,8 @@ setup:
4747
"Get template with local flag":
4848

4949
- skip:
50-
version: " - 5.99.99"
51-
reason: this uses a new API that has been added in 6.0
50+
version: " - 5.99.99"
51+
reason: this uses a new API that has been added in 6.0
5252

5353
- do:
5454
indices.get_template:
@@ -61,8 +61,8 @@ setup:
6161
"Get template with flat settings and master timeout":
6262

6363
- skip:
64-
version: " - 5.99.99"
65-
reason: this uses a new API that has been added in 6.0
64+
version: " - 5.99.99"
65+
reason: this uses a new API that has been added in 6.0
6666

6767
- do:
6868
indices.get_template:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_template/10_basic.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"Put template":
33

44
- skip:
5-
version: " - 5.99.99"
6-
reason: this uses a new API that has been added in 6.0
5+
version: " - 5.99.99"
6+
reason: this uses a new API that has been added in 6.0
77

88
- do:
99
indices.put_template:
@@ -26,8 +26,8 @@
2626
"Put multiple template":
2727

2828
- skip:
29-
version: " - 5.99.99"
30-
reason: this uses a new API that has been added in 6.0
29+
version: " - 5.99.99"
30+
reason: this uses a new API that has been added in 6.0
3131

3232
- do:
3333
indices.put_template:
@@ -50,8 +50,8 @@
5050
"Put template with aliases":
5151

5252
- skip:
53-
version: " - 5.99.99"
54-
reason: this uses a new API that has been added in 6.0
53+
version: " - 5.99.99"
54+
reason: this uses a new API that has been added in 6.0
5555

5656
- do:
5757
indices.put_template:
@@ -78,8 +78,8 @@
7878
"Put template create":
7979

8080
- skip:
81-
version: " - 5.99.99"
82-
reason: this uses a new API that has been added in 6.0
81+
version: " - 5.99.99"
82+
reason: this uses a new API that has been added in 6.0
8383

8484
- do:
8585
indices.put_template:
@@ -114,8 +114,8 @@
114114
"Test Put Versioned Template":
115115

116116
- skip:
117-
version: " - 5.99.99"
118-
reason: this uses a new API that has been added in 6.0
117+
version: " - 5.99.99"
118+
reason: this uses a new API that has been added in 6.0
119119

120120
- do:
121121
indices.put_template:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.upgrade/10_basic.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
---
2020
"Upgrade indices ignore unavailable":
2121
- skip:
22-
version: " - 5.0.0"
23-
reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281
22+
version: " - 5.0.0"
23+
reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281
2424

2525
- do:
2626
indices.create:
@@ -44,8 +44,8 @@
4444
"Upgrade indices allow no indices":
4545

4646
- skip:
47-
version: " - 5.0.0"
48-
reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281
47+
version: " - 5.0.0"
48+
reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281
4949

5050
- do:
5151
indices.upgrade:
@@ -59,8 +59,8 @@
5959
"Upgrade indices disallow no indices":
6060

6161
- skip:
62-
version: " - 5.0.0"
63-
reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281
62+
version: " - 5.0.0"
63+
reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281
6464

6565
- do:
6666
catch: missing
@@ -73,8 +73,8 @@
7373
"Upgrade indices disallow unavailable":
7474

7575
- skip:
76-
version: " - 5.0.0"
77-
reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281
76+
version: " - 5.0.0"
77+
reason: ignore_unavailable was added as a bugfix in 5.0.1 see #21281
7878

7979
- do:
8080
indices.create:

rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/20_terms.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ setup:
288288
---
289289
"Scaled float test":
290290
- skip:
291-
version: " - 5.2.0"
292-
reason: scaled_float were considered as longs in aggregations, this was fixed in 5.2.0
291+
version: " - 5.2.0"
292+
reason: scaled_float were considered as longs in aggregations, this was fixed in 5.2.0
293293

294294
- do:
295295
index:
@@ -409,9 +409,9 @@ setup:
409409
"Partitioned string test":
410410

411411
- skip:
412-
version: " - 5.1.99"
413-
reason: Partitioning is a 5.2.0 feature
414-
412+
version: " - 5.1.99"
413+
reason: Partitioning is a 5.2.0 feature
414+
415415
- do:
416416
index:
417417
index: test_1
@@ -468,8 +468,8 @@ setup:
468468
"Partitioned integer test":
469469

470470
- skip:
471-
version: " - 5.1.99"
472-
reason: Partitioning is a 5.2.0 feature
471+
version: " - 5.1.99"
472+
reason: Partitioning is a 5.2.0 feature
473473

474474
- do:
475475
index:
@@ -650,7 +650,7 @@ setup:
650650
index:
651651
index: test_1
652652
type: test
653-
id: 1
653+
id: 1
654654
body: {}
655655

656656
- do:

0 commit comments

Comments
 (0)