mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
No refresh on shard activation needed (#28013)
A shard is fully baked when it moves to POST_RECOVERY. There is no need to do an extra refresh on shard activation again as the shard has already been refreshed when it moved to POST_RECOVERY.
This commit is contained in:
parent
d43f0b5f26
commit
c8df446000
@ -407,12 +407,6 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
|
||||
|
||||
if (state == IndexShardState.POST_RECOVERY && newRouting.active()) {
|
||||
assert currentRouting.active() == false : "we are in POST_RECOVERY, but our shard routing is active " + currentRouting;
|
||||
// we want to refresh *before* we move to internal STARTED state
|
||||
try {
|
||||
getEngine().refresh("cluster_state_started");
|
||||
} catch (Exception e) {
|
||||
logger.debug("failed to refresh due to move to cluster wide started", e);
|
||||
}
|
||||
|
||||
if (newRouting.primary() && currentRouting.isRelocationTarget() == false) {
|
||||
replicationTracker.activatePrimaryMode(getEngine().getLocalCheckpointTracker().getCheckpoint());
|
||||
|
@ -1170,14 +1170,14 @@ public class IndexShardTests extends IndexShardTestCase {
|
||||
|
||||
public void testRefreshMetric() throws IOException {
|
||||
IndexShard shard = newStartedShard();
|
||||
assertThat(shard.refreshStats().getTotal(), equalTo(3L)); // refresh on: finalize, end of recovery and on starting shard
|
||||
assertThat(shard.refreshStats().getTotal(), equalTo(2L)); // refresh on: finalize and end of recovery
|
||||
long initialTotalTime = shard.refreshStats().getTotalTimeInMillis();
|
||||
// check time advances
|
||||
for (int i = 1; shard.refreshStats().getTotalTimeInMillis() == initialTotalTime; i++) {
|
||||
indexDoc(shard, "test", "test");
|
||||
assertThat(shard.refreshStats().getTotal(), equalTo(3L + i - 1));
|
||||
assertThat(shard.refreshStats().getTotal(), equalTo(2L + i - 1));
|
||||
shard.refresh("test");
|
||||
assertThat(shard.refreshStats().getTotal(), equalTo(3L + i));
|
||||
assertThat(shard.refreshStats().getTotal(), equalTo(2L + i));
|
||||
assertThat(shard.refreshStats().getTotalTimeInMillis(), greaterThanOrEqualTo(initialTotalTime));
|
||||
}
|
||||
long refreshCount = shard.refreshStats().getTotal();
|
||||
|
Loading…
x
Reference in New Issue
Block a user