-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 issue of red index on close for remote enabled clusters #15990
Open
ashking94
wants to merge
1
commit into
opensearch-project:main
Choose a base branch
from
ashking94:fix-issue-15989
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+89
−4
Open
Changes from all commits
Commits
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
import org.opensearch.action.admin.indices.settings.put.UpdateSettingsRequest; | ||
import org.opensearch.action.index.IndexResponse; | ||
import org.opensearch.action.search.SearchPhaseExecutionException; | ||
import org.opensearch.client.Requests; | ||
import org.opensearch.cluster.health.ClusterHealthStatus; | ||
import org.opensearch.cluster.metadata.IndexMetadata; | ||
import org.opensearch.cluster.routing.RecoverySource; | ||
|
@@ -202,7 +203,7 @@ public void testRemoteTranslogCleanup() throws Exception { | |
|
||
public void testStaleCommitDeletionWithInvokeFlush() throws Exception { | ||
String dataNode = internalCluster().startNode(); | ||
createIndex(INDEX_NAME, remoteStoreIndexSettings(1, 10000l, -1)); | ||
createIndex(INDEX_NAME, remoteStoreIndexSettings(1, 10000L, -1)); | ||
int numberOfIterations = randomIntBetween(5, 15); | ||
indexData(numberOfIterations, true, INDEX_NAME); | ||
String segmentsPathFixedPrefix = RemoteStoreSettings.CLUSTER_REMOTE_STORE_SEGMENTS_PATH_PREFIX.get(getNodeSettings()); | ||
|
@@ -1011,4 +1012,73 @@ public void testAsyncTranslogDurabilityRestrictionsThroughIdxTemplates() throws | |
.get() | ||
); | ||
} | ||
|
||
public void testCloseIndexWithNoOpSyncAndFlushForSyncTranslog() throws InterruptedException { | ||
internalCluster().startNodes(3); | ||
client().admin() | ||
.cluster() | ||
.prepareUpdateSettings() | ||
.setTransientSettings(Settings.builder().put(CLUSTER_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING.getKey(), "5s")) | ||
.get(); | ||
Settings.Builder settings = Settings.builder() | ||
.put(remoteStoreIndexSettings(0, 10000L, -1)) | ||
.put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "1s"); | ||
createIndex(INDEX_NAME, settings.build()); | ||
CountDownLatch latch = new CountDownLatch(1); | ||
new Thread(() -> { | ||
if (randomBoolean()) { | ||
for (int i = 0; i < randomIntBetween(1, 5); i++) { | ||
indexSingleDoc(INDEX_NAME); | ||
} | ||
flushAndRefresh(INDEX_NAME); | ||
} | ||
// Index single doc to start the asyn io processor to run which will lead to 10s wait time before the next sync. | ||
indexSingleDoc(INDEX_NAME); | ||
// Reduce the latch for the main thread to flush after some sleep. | ||
latch.countDown(); | ||
// Index another doc and in this case the flush would have happened before the sync. | ||
indexSingleDoc(INDEX_NAME); | ||
}).start(); | ||
// Wait for atleast one doc to be ingested. | ||
latch.await(); | ||
// Sleep for some time for the next doc to be present in lucene buffer. If flush happens first before the doc #2 | ||
// gets indexed, then it goes into the happy case where the close index happens succefully. | ||
Thread.sleep(1000); | ||
// Flush so that the subsequent sync or flushes are no-op. | ||
flush(INDEX_NAME); | ||
// Closing the index involves translog.sync and shard.flush which are now no-op. | ||
client().admin().indices().close(Requests.closeIndexRequest(INDEX_NAME)).actionGet(); | ||
Thread.sleep(10000); | ||
ensureGreen(INDEX_NAME); | ||
} | ||
|
||
public void testCloseIndexWithNoOpSyncAndFlushForAsyncTranslog() throws InterruptedException { | ||
internalCluster().startNodes(3); | ||
Settings.Builder settings = Settings.builder() | ||
.put(remoteStoreIndexSettings(0, 10000L, -1)) | ||
.put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "1s") | ||
.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Durability.ASYNC) | ||
.put(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey(), "10s"); | ||
createIndex(INDEX_NAME, settings.build()); | ||
CountDownLatch latch = new CountDownLatch(1); | ||
new Thread(() -> { | ||
// Index some docs to start the asyn io processor to run which will lead to 10s wait time before the next sync. | ||
indexSingleDoc(INDEX_NAME); | ||
indexSingleDoc(INDEX_NAME); | ||
indexSingleDoc(INDEX_NAME); | ||
// Reduce the latch for the main thread to flush after some sleep. | ||
latch.countDown(); | ||
}).start(); | ||
// Wait for atleast one doc to be ingested. | ||
latch.await(); | ||
// Sleep for some time for the next doc to be present in lucene buffer. If flush happens first before the doc #2 | ||
// gets indexed, then it goes into the happy case where the close index happens succefully. | ||
Thread.sleep(1000); | ||
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. curious why do we need sleep here ? As we have already indexed docs and they should be in lucene buffer. |
||
// Flush so that the subsequent sync or flushes are no-op. | ||
flush(INDEX_NAME); | ||
// Closing the index involves translog.sync and shard.flush which are now no-op. | ||
client().admin().indices().close(Requests.closeIndexRequest(INDEX_NAME)).actionGet(); | ||
Thread.sleep(10000); | ||
ensureGreen(INDEX_NAME); | ||
} | ||
} |
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
Oops, something went wrong.
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 we write UTs as well for same ?