Skip to content

Commit cc61ad4

Browse files
committed
More change
Signed-off-by: Gaurav Bafna <[email protected]>
1 parent 1a9da53 commit cc61ad4

File tree

4 files changed

+157
-111
lines changed

4 files changed

+157
-111
lines changed

server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteRestoreSnapshotIT.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,61 @@ public void testConcurrentSnapshotV2CreateOperation() throws InterruptedExceptio
997997
assertThat(repositoryData.getSnapshotIds().size(), greaterThanOrEqualTo(1));
998998
}
999999

1000+
public void testConcurrentSnapshotV2CreateOperation_MasterChange() throws InterruptedException, ExecutionException, IOException {
1001+
internalCluster().startClusterManagerOnlyNode(pinnedTimestampSettings());
1002+
internalCluster().startClusterManagerOnlyNode(pinnedTimestampSettings());
1003+
internalCluster().startClusterManagerOnlyNode(pinnedTimestampSettings());
1004+
internalCluster().startDataOnlyNode(pinnedTimestampSettings());
1005+
internalCluster().startDataOnlyNode(pinnedTimestampSettings());
1006+
String indexName1 = "testindex1";
1007+
String indexName2 = "testindex2";
1008+
String snapshotRepoName = "test-create-snapshot-repo";
1009+
Path absolutePath1 = randomRepoPath().toAbsolutePath();
1010+
logger.info("Snapshot Path [{}]", absolutePath1);
1011+
1012+
Settings.Builder settings = Settings.builder()
1013+
.put(FsRepository.LOCATION_SETTING.getKey(), absolutePath1)
1014+
.put(FsRepository.COMPRESS_SETTING.getKey(), randomBoolean())
1015+
.put(FsRepository.CHUNK_SIZE_SETTING.getKey(), randomIntBetween(100, 1000), ByteSizeUnit.BYTES)
1016+
.put(BlobStoreRepository.REMOTE_STORE_INDEX_SHALLOW_COPY.getKey(), true)
1017+
.put(BlobStoreRepository.SHALLOW_SNAPSHOT_V2.getKey(), true);
1018+
createRepository(snapshotRepoName, FsRepository.TYPE, settings);
1019+
1020+
Client client = client();
1021+
Settings indexSettings = getIndexSettings(20, 0).build();
1022+
createIndex(indexName1, indexSettings);
1023+
1024+
Settings indexSettings2 = getIndexSettings(15, 0).build();
1025+
createIndex(indexName2, indexSettings2);
1026+
1027+
final int numDocsInIndex1 = 10;
1028+
final int numDocsInIndex2 = 20;
1029+
indexDocuments(client, indexName1, numDocsInIndex1);
1030+
indexDocuments(client, indexName2, numDocsInIndex2);
1031+
ensureGreen(indexName1, indexName2);
1032+
1033+
int concurrentSnapshots = 5;
1034+
1035+
String snapshotName = "snapshot-concurrent-";
1036+
CreateSnapshotResponse createSnapshotResponse2 = client().admin()
1037+
.cluster()
1038+
.prepareCreateSnapshot(snapshotRepoName, snapshotName)
1039+
.setWaitForCompletion(false)
1040+
.get();
1041+
1042+
//restart existing master
1043+
final String clusterManagerNode = internalCluster().getClusterManagerName();
1044+
stopNode(clusterManagerNode);
1045+
1046+
// Validate that only one snapshot has been created
1047+
Repository repository = internalCluster().getInstance(RepositoriesService.class).repository(snapshotRepoName);
1048+
PlainActionFuture<RepositoryData> repositoryDataPlainActionFuture = new PlainActionFuture<>();
1049+
repository.getRepositoryData(repositoryDataPlainActionFuture);
1050+
1051+
RepositoryData repositoryData = repositoryDataPlainActionFuture.get();
1052+
assertEquals(repositoryData.getSnapshotIds().size() , 0);
1053+
}
1054+
10001055
public void testCreateSnapshotV2WithRedIndex() throws Exception {
10011056
internalCluster().startClusterManagerOnlyNode(pinnedTimestampSettings());
10021057
internalCluster().startDataOnlyNode(pinnedTimestampSettings());

server/src/main/java/org/opensearch/cluster/SnapshotsInProgress.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public static Entry startClone(
202202
Map.of(),
203203
false,
204204
false// initialising to false, will be updated in startCloning method of SnapshotsService while updating entry with
205-
// clone jobs
205+
// clone jobs
206206
);
207207
}
208208

@@ -231,7 +231,8 @@ public static Entry startClone(
231231
source,
232232
Map.of(),
233233
remoteStoreIndexShallowCopyV2,
234-
remoteStoreIndexShallowCopyV2// initialising to false, will be updated in startCloning method of SnapshotsService while updating entry with
234+
remoteStoreIndexShallowCopyV2// initialising to false, will be updated in startCloning method of SnapshotsService while updating
235+
// entry with
235236
// clone jobs
236237
);
237238
}
@@ -388,7 +389,8 @@ public Entry(
388389
}
389390
this.remoteStoreIndexShallowCopy = remoteStoreIndexShallowCopy;
390391
this.remoteStoreIndexShallowCopyV2 = remoteStoreIndexShallowCopyV2;
391-
assert this.remoteStoreIndexShallowCopyV2 || assertShardsConsistent(this.source, this.state, this.indices, this.shards, this.clones);
392+
assert this.remoteStoreIndexShallowCopyV2
393+
|| assertShardsConsistent(this.source, this.state, this.indices, this.shards, this.clones);
392394
}
393395

394396
private Entry(StreamInput in) throws IOException {

server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,7 @@ public void finalizeSnapshot(
24412441
// number_of_shards) has increased.
24422442
Set<String> updatedIndexIds = writeNewIndexShardPaths(existingRepositoryData, updatedRepositoryData, snapshotId);
24432443
cleanupRedundantSnapshotShardPaths(updatedIndexIds);
2444+
logger.info("update repo data for {}", snapshotInfo.snapshotId());
24442445
writeIndexGen(
24452446
updatedRepositoryData,
24462447
repositoryStateId,
@@ -3224,6 +3225,7 @@ public ClusterState execute(ClusterState currentState) {
32243225
+ "] must be larger than latest known generation ["
32253226
+ latestKnownRepoGen.get()
32263227
+ "]";
3228+
logger.info("Setting it to {} {}", safeGeneration, newGen);
32273229
return ClusterState.builder(currentState)
32283230
.metadata(
32293231
Metadata.builder(currentState.getMetadata())
@@ -3344,6 +3346,7 @@ public ClusterState execute(ClusterState currentState) {
33443346
+ "]"
33453347
);
33463348
}
3349+
logger.info("Done Setting it to {} {}", newGen, newGen);
33473350
return updateRepositoryGenerationsIfNecessary(
33483351
stateFilter.apply(
33493352
ClusterState.builder(currentState)

0 commit comments

Comments
 (0)