-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relax NoOpEngine constraints (#37413)
When a NoOpEngine is instanciated, the current implementation verifies that the translog contains no operations and that it contains the same UUID as the last Lucene commit data.We can relax those two constraints because the Close Index API now ensure that all translog operations are flushed before closing a shard. The detection of coherence between translog UUID / Lucene commit data is not specific to NoOpEngine, and is already done by IndexShard.innerOpenEngineAndTranslog(). Related to #33888
- Loading branch information
Showing
3 changed files
with
58 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
server/src/test/java/org/elasticsearch/index/engine/NoOpEngineRecoveryTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.index.engine; | ||
|
||
import org.elasticsearch.cluster.routing.RecoverySource.ExistingStoreRecoverySource; | ||
import org.elasticsearch.cluster.routing.ShardRouting; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.index.shard.IndexShard; | ||
import org.elasticsearch.index.shard.IndexShardTestCase; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.elasticsearch.cluster.routing.ShardRoutingHelper.initWithSameId; | ||
|
||
public class NoOpEngineRecoveryTests extends IndexShardTestCase { | ||
|
||
public void testRecoverFromNoOp() throws IOException { | ||
final int nbDocs = scaledRandomIntBetween(1, 100); | ||
|
||
final IndexShard indexShard = newStartedShard(true); | ||
for (int i = 0; i < nbDocs; i++) { | ||
indexDoc(indexShard, "_doc", String.valueOf(i)); | ||
} | ||
indexShard.close("test", true); | ||
|
||
final ShardRouting shardRouting = indexShard.routingEntry(); | ||
IndexShard primary = reinitShard(indexShard, initWithSameId(shardRouting, ExistingStoreRecoverySource.INSTANCE), NoOpEngine::new); | ||
recoverShardFromStore(primary); | ||
assertEquals(primary.seqNoStats().getMaxSeqNo(), primary.getMaxSeqNoOfUpdatesOrDeletes()); | ||
assertEquals(nbDocs, primary.docStats().getCount()); | ||
|
||
IndexShard replica = newShard(false, Settings.EMPTY, NoOpEngine::new); | ||
recoverReplica(replica, primary, true); | ||
assertEquals(replica.seqNoStats().getMaxSeqNo(), replica.getMaxSeqNoOfUpdatesOrDeletes()); | ||
assertEquals(nbDocs, replica.docStats().getCount()); | ||
closeShards(primary, replica); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters