Skip to content

Commit 71dbc22

Browse files
authored
Revert "[Remote Store] Fix sleep time bug during remote store sync (opensearch-project#14037)" (opensearch-project#14274)
This reverts commit afeddc2. Signed-off-by: Gaurav Bafna <[email protected]>
1 parent 8af4647 commit 71dbc22

File tree

3 files changed

+25
-32
lines changed

3 files changed

+25
-32
lines changed

server/src/internalClusterTest/java/org/opensearch/remotemigration/MigrationBaseTestCase.java

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,18 @@
99
package org.opensearch.remotemigration;
1010

1111
import org.opensearch.action.DocWriteResponse;
12-
import org.opensearch.action.admin.cluster.health.ClusterHealthRequest;
13-
import org.opensearch.action.admin.cluster.health.ClusterHealthResponse;
1412
import org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
1513
import org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse;
1614
import org.opensearch.action.bulk.BulkRequest;
1715
import org.opensearch.action.bulk.BulkResponse;
1816
import org.opensearch.action.delete.DeleteResponse;
1917
import org.opensearch.action.index.IndexRequest;
2018
import org.opensearch.action.index.IndexResponse;
21-
import org.opensearch.client.Requests;
2219
import org.opensearch.cluster.ClusterState;
23-
import org.opensearch.cluster.health.ClusterHealthStatus;
2420
import org.opensearch.cluster.metadata.RepositoryMetadata;
2521
import org.opensearch.cluster.routing.RoutingNode;
26-
import org.opensearch.common.Priority;
2722
import org.opensearch.common.UUIDs;
2823
import org.opensearch.common.settings.Settings;
29-
import org.opensearch.common.unit.TimeValue;
3024
import org.opensearch.repositories.fs.ReloadableFsRepository;
3125
import org.opensearch.test.OpenSearchIntegTestCase;
3226
import org.junit.Before;
@@ -45,7 +39,6 @@
4539
import static org.opensearch.node.remotestore.RemoteStoreNodeService.REMOTE_STORE_COMPATIBILITY_MODE_SETTING;
4640
import static org.opensearch.repositories.fs.ReloadableFsRepository.REPOSITORIES_FAILRATE_SETTING;
4741
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
48-
import static org.hamcrest.Matchers.equalTo;
4942

5043
public class MigrationBaseTestCase extends OpenSearchIntegTestCase {
5144
protected static final String REPOSITORY_NAME = "test-remote-store-repo";
@@ -121,10 +114,6 @@ public void initDocRepToRemoteMigration() {
121114
);
122115
}
123116

124-
public ClusterHealthStatus ensureGreen(String... indices) {
125-
return ensureGreen(TimeValue.timeValueSeconds(60), indices);
126-
}
127-
128117
public BulkResponse indexBulk(String indexName, int numDocs) {
129118
BulkRequest bulkRequest = new BulkRequest();
130119
for (int i = 0; i < numDocs; i++) {
@@ -192,12 +181,14 @@ private Thread getIndexingThread() {
192181
long currentDocCount = indexedDocs.incrementAndGet();
193182
if (currentDocCount > 0 && currentDocCount % refreshFrequency == 0) {
194183
if (rarely()) {
184+
logger.info("--> [iteration {}] flushing index", currentDocCount);
195185
client().admin().indices().prepareFlush(indexName).get();
196-
logger.info("Completed ingestion of {} docs. Flushing now", currentDocCount);
197186
} else {
187+
logger.info("--> [iteration {}] refreshing index", currentDocCount);
198188
client().admin().indices().prepareRefresh(indexName).get();
199189
}
200190
}
191+
logger.info("Completed ingestion of {} docs", currentDocCount);
201192
}
202193
});
203194
}
@@ -227,21 +218,4 @@ public void stopShardRebalancing() {
227218
.get()
228219
);
229220
}
230-
231-
public ClusterHealthStatus waitForRelocation() {
232-
ClusterHealthRequest request = Requests.clusterHealthRequest()
233-
.waitForNoRelocatingShards(true)
234-
.timeout(TimeValue.timeValueSeconds(60))
235-
.waitForEvents(Priority.LANGUID);
236-
ClusterHealthResponse actionGet = client().admin().cluster().health(request).actionGet();
237-
if (actionGet.isTimedOut()) {
238-
logger.info(
239-
"waitForRelocation timed out, cluster state:\n{}\n{}",
240-
client().admin().cluster().prepareState().get().getState(),
241-
client().admin().cluster().preparePendingClusterTasks().get()
242-
);
243-
assertThat("timed out waiting for relocation", actionGet.isTimedOut(), equalTo(false));
244-
}
245-
return actionGet.getStatus();
246-
}
247221
}

server/src/internalClusterTest/java/org/opensearch/remotemigration/RemotePrimaryRelocationIT.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,16 @@ public void testRemotePrimaryRelocation() throws Exception {
9999
.add(new MoveAllocationCommand("test", 0, primaryNodeName("test"), remoteNode))
100100
.execute()
101101
.actionGet();
102-
waitForRelocation();
102+
ClusterHealthResponse clusterHealthResponse = client().admin()
103+
.cluster()
104+
.prepareHealth()
105+
.setTimeout(TimeValue.timeValueSeconds(60))
106+
.setWaitForEvents(Priority.LANGUID)
107+
.setWaitForNoRelocatingShards(true)
108+
.execute()
109+
.actionGet();
110+
111+
assertEquals(0, clusterHealthResponse.getRelocatingShards());
103112
assertEquals(remoteNode, primaryNodeName("test"));
104113
logger.info("--> relocation from docrep to remote complete");
105114

@@ -114,7 +123,16 @@ public void testRemotePrimaryRelocation() throws Exception {
114123
.add(new MoveAllocationCommand("test", 0, remoteNode, remoteNode2))
115124
.execute()
116125
.actionGet();
117-
waitForRelocation();
126+
clusterHealthResponse = client().admin()
127+
.cluster()
128+
.prepareHealth()
129+
.setTimeout(TimeValue.timeValueSeconds(60))
130+
.setWaitForEvents(Priority.LANGUID)
131+
.setWaitForNoRelocatingShards(true)
132+
.execute()
133+
.actionGet();
134+
135+
assertEquals(0, clusterHealthResponse.getRelocatingShards());
118136
assertEquals(remoteNode2, primaryNodeName("test"));
119137

120138
logger.info("--> relocation from remote to remote complete");
@@ -137,6 +155,7 @@ public void testRemotePrimaryRelocation() throws Exception {
137155

138156
public void testMixedModeRelocation_RemoteSeedingFail() throws Exception {
139157
String docRepNode = internalCluster().startNode();
158+
Client client = internalCluster().client(docRepNode);
140159
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest();
141160
updateSettingsRequest.persistentSettings(Settings.builder().put(REMOTE_STORE_COMPATIBILITY_MODE_SETTING.getKey(), "mixed"));
142161
assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet());

server/src/main/java/org/opensearch/index/shard/IndexShard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ public void waitForRemoteStoreSync(Runnable onProgress) throws IOException {
21462146
segmentUploadeCount = directory.getSegmentsUploadedToRemoteStore().size();
21472147
}
21482148
try {
2149-
Thread.sleep(TimeValue.timeValueSeconds(30).millis());
2149+
Thread.sleep(TimeValue.timeValueSeconds(30).seconds());
21502150
} catch (InterruptedException ie) {
21512151
throw new OpenSearchException("Interrupted waiting for completion of [{}]", ie);
21522152
}

0 commit comments

Comments
 (0)