@@ -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 ());
0 commit comments