-
Notifications
You must be signed in to change notification settings - Fork 24.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix missing historyUUID in peer recovery when rolling upgrade 5.x to 6.3 #31506
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import org.apache.http.entity.StringEntity; | ||
import org.apache.http.util.EntityUtils; | ||
import org.elasticsearch.Version; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
import org.elasticsearch.common.Booleans; | ||
|
@@ -788,6 +789,45 @@ public void testRecovery() throws Exception { | |
} | ||
} | ||
|
||
/** | ||
* Tests that a synced-flushed index is correctly recovered. | ||
* This might be an edge-case from 5.x to 6.x since a 5.x index commit does not have all required 6.x commit tags. | ||
*/ | ||
public void testRecoverSyncedFlushIndex() throws Exception { | ||
final int count; | ||
if (runningAgainstOldCluster) { | ||
Settings.Builder settings = Settings.builder() | ||
.put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) | ||
.put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1) | ||
// if the node with the replica is the first to be restarted, while a replica is still recovering | ||
// then delayed allocation will kick in. When the node comes back, the master will search for a copy | ||
// but the recovering copy will be seen as invalid and the cluster health won't return to GREEN | ||
// before timing out | ||
.put(INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "100ms") | ||
.put(SETTING_ALLOCATION_MAX_RETRY.getKey(), "0"); // fail faster | ||
createIndex(index, settings.build()); | ||
count = randomInt(10); | ||
indexRandomDocuments(count, randomBoolean(), randomBoolean(), | ||
n -> JsonXContent.contentBuilder().startObject().field("key", "value").endObject()); | ||
// We have to spin synced-flush requests here because we fire the global checkpoint sync for the last write operation. | ||
// A synced-flush request considers the global checkpoint sync as an going operation because it acquires a shard permit. | ||
assertBusy(() -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we replace this assertBusy by an ensureGreen(index)? |
||
Response resp = client().performRequest(new Request("POST", index + "/_flush/synced")); | ||
assertOK(resp); | ||
Map<String, Object> result = ObjectPath.createFromResponse(resp).evaluate("_shards"); | ||
assertThat(result.get("successful"), equalTo(2)); | ||
}); | ||
} else { | ||
count = countOfIndexedRandomDocuments(); | ||
} | ||
ensureGreen(index); | ||
refresh(); | ||
Request countRequest = new Request("GET", "/" + index + "/_search"); | ||
countRequest.addParameter("size", "0"); | ||
String countResponse = toStr(client().performRequest(countRequest)); | ||
assertThat(countResponse, containsString("\"total\":" + count)); | ||
} | ||
|
||
/** | ||
* Tests snapshot/restore by creating a snapshot and restoring it. It takes | ||
* a snapshot on the old cluster and restores it on the old cluster as a | ||
|
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import org.apache.http.entity.StringEntity; | ||
import org.elasticsearch.Version; | ||
import org.elasticsearch.action.support.PlainActionFuture; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
import org.elasticsearch.common.settings.Settings; | ||
|
@@ -285,4 +286,29 @@ public void testSearchGeoPoints() throws Exception { | |
} | ||
} | ||
|
||
public void testRecoverSyncedFlushIndex() throws Exception { | ||
final String index = "recover_synced_flush_index"; | ||
if (CLUSTER_TYPE == ClusterType.OLD) { | ||
Settings.Builder settings = Settings.builder() | ||
.put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) | ||
.put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1) | ||
// if the node with the replica is the first to be restarted, while a replica is still recovering | ||
// then delayed allocation will kick in. When the node comes back, the master will search for a copy | ||
// but the recovering copy will be seen as invalid and the cluster health won't return to GREEN | ||
// before timing out | ||
.put(INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "100ms") | ||
.put(SETTING_ALLOCATION_MAX_RETRY.getKey(), "0"); // fail faster | ||
createIndex(index, settings.build()); | ||
indexDocs(index, 0, randomInt(5)); | ||
// We have to spin synced-flush requests here because we fire the global checkpoint sync for the last write operation. | ||
// A synced-flush request considers the global checkpoint sync as an going operation because it acquires a shard permit. | ||
assertBusy(() -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above, replace by ensureGreen()? |
||
Response resp = client().performRequest(new Request("POST", index + "/_flush/synced")); | ||
assertOK(resp); | ||
Map<String, Object> result = ObjectPath.createFromResponse(resp).evaluate("_shards"); | ||
assertThat(result.get("successful"), equalTo(2)); | ||
}); | ||
} | ||
ensureGreen(index); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we fold this into testRecovery and randomly do a synced flush instead of a normal flush?