-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IGNITE-23220 Avoid concurrent Catalog writes to Metastorage on the sa…
…me node
- Loading branch information
Showing
3 changed files
with
102 additions
and
1 deletion.
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
69 changes: 69 additions & 0 deletions
69
.../src/integrationTest/java/org/apache/ignite/internal/catalog/it/ItConcurrentDdlsTest.java
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.catalog.it; | ||
|
||
import static java.util.concurrent.TimeUnit.SECONDS; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
import java.util.concurrent.ForkJoinPool; | ||
import java.util.stream.IntStream; | ||
import org.apache.ignite.internal.ClusterPerTestIntegrationTest; | ||
import org.apache.ignite.internal.catalog.CatalogService; | ||
import org.apache.ignite.internal.util.IgniteUtils; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ItConcurrentDdlsTest extends ClusterPerTestIntegrationTest { | ||
private static final String ZONE_NAME = "TEST_ZONE"; | ||
|
||
@Override | ||
protected int initialNodes() { | ||
return 1; | ||
} | ||
|
||
/** | ||
* Makes sure we can request DDLs with high concurrency and not fall into 'no more retry attempts' trap. | ||
*/ | ||
@Test | ||
void createTablesConcurrently() { | ||
// Just 1 partition to make the test lighter and faster (number of partitions is not the focus of this test). | ||
createZoneWith1Partition(); | ||
|
||
ForkJoinPool pool = new ForkJoinPool(10); | ||
|
||
assertDoesNotThrow(() -> pool.submit(this::createTablesInParallel).get()); | ||
|
||
IgniteUtils.shutdownAndAwaitTermination(pool, 10, SECONDS); | ||
} | ||
|
||
private void createZoneWith1Partition() { | ||
node(0).sql().executeScript( | ||
"CREATE ZONE " + ZONE_NAME + " with partitions=1, replicas=1, storage_profiles='" | ||
+ CatalogService.DEFAULT_STORAGE_PROFILE + "'" | ||
); | ||
} | ||
|
||
private void createTablesInParallel() { | ||
IntStream.range(0, 30).parallel().forEach(n -> { | ||
String tableName = "TEST" + n; | ||
|
||
node(0).sql().executeScript( | ||
"CREATE TABLE " + tableName + " (id INT PRIMARY KEY, val VARCHAR) WITH primary_zone='" + ZONE_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