zstan commented on code in PR #2712:
URL: https://github.com/apache/ignite-3/pull/2712#discussion_r1398763015
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItBuildIndexTest.java:
##########
@@ -275,6 +284,10 @@ private static void checkIndexBuild(int partitions, int
replicas, String indexNa
IgniteStringFormatter.format("p={}, nodes={}",
entry.getKey(), entry.getValue())
);
}
+
+ waitForCondition(() -> isIndexAvailable(INDEX_NAME), 10_000);
Review Comment:
```suggestion
assertTrue(waitForCondition(() -> isIndexAvailable(INDEX_NAME),
10_000));
```
##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItBuildIndexTest.java:
##########
@@ -275,6 +284,10 @@ private static void checkIndexBuild(int partitions, int
replicas, String indexNa
IgniteStringFormatter.format("p={}, nodes={}",
entry.getKey(), entry.getValue())
);
}
+
+ waitForCondition(() -> isIndexAvailable(INDEX_NAME), 10_000);
+
+ waitForReadTimestampThatObservesMostRecentCatalog();
Review Comment:
why do we need this additional awaiting code ?
##########
modules/runner/src/testFixtures/java/org/apache/ignite/internal/ClusterPerClassIntegrationTest.java:
##########
@@ -227,4 +266,64 @@ public Person(int id, String name, double salary) {
this.salary = salary;
}
}
+
+ /**
+ * Waits for some amount of time so that read-only transactions can
observe the most recent version of the catalog.
+ */
+ protected static void waitForReadTimestampThatObservesMostRecentCatalog()
{
+ // See TxManagerImpl::currentReadTimestamp.
+ long delay = HybridTimestamp.CLOCK_SKEW +
TestIgnitionManager.DEFAULT_PARTITION_IDLE_SYNC_TIME_INTERVAL_MS;
+ try {
+ TimeUnit.MILLISECONDS.sleep(delay);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static List<List<Object>> executeAwaitingIndexes(IgniteImpl node,
Function<IgniteImpl, List<List<Object>>> statement) {
+ CatalogManager catalogManager = node.catalogManager();
+
+ // Get existing indexes
+ Set<Integer> existing =
catalogManager.indexes(catalogManager.latestCatalogVersion())
+ .stream().map(CatalogObjectDescriptor::id)
+ .collect(Collectors.toSet());
+
+ List<List<Object>> result = statement.apply(node);
+
+ // Get indexes after a statement and compute the difference
+ Set<Integer> difference =
catalogManager.indexes(catalogManager.latestCatalogVersion()).stream()
+ .map(CatalogObjectDescriptor::id)
+ .collect(Collectors.toSet());
+
+ difference.removeAll(existing);
+
+ if (difference.isEmpty()) {
+ return result;
+ }
+
+ // If there are new indexes, wait for them to become available.
+
+ try {
+ waitForCondition(() -> {
Review Comment:
```suggestion
assertTrue(waitForCondition(() -> {
```
##########
modules/runner/src/testFixtures/java/org/apache/ignite/internal/ClusterPerClassIntegrationTest.java:
##########
@@ -227,4 +266,64 @@ public Person(int id, String name, double salary) {
this.salary = salary;
}
}
+
+ /**
+ * Waits for some amount of time so that read-only transactions can
observe the most recent version of the catalog.
+ */
+ protected static void waitForReadTimestampThatObservesMostRecentCatalog()
{
+ // See TxManagerImpl::currentReadTimestamp.
+ long delay = HybridTimestamp.CLOCK_SKEW +
TestIgnitionManager.DEFAULT_PARTITION_IDLE_SYNC_TIME_INTERVAL_MS;
+ try {
+ TimeUnit.MILLISECONDS.sleep(delay);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static List<List<Object>> executeAwaitingIndexes(IgniteImpl node,
Function<IgniteImpl, List<List<Object>>> statement) {
+ CatalogManager catalogManager = node.catalogManager();
+
+ // Get existing indexes
+ Set<Integer> existing =
catalogManager.indexes(catalogManager.latestCatalogVersion())
+ .stream().map(CatalogObjectDescriptor::id)
+ .collect(Collectors.toSet());
+
+ List<List<Object>> result = statement.apply(node);
Review Comment:
seems that you use statement execution like some kind of edge between
existing and possibly new indexes ? Is it correct ? Or i miss smth ? Probably
this guarantee is enough here but it`s not clear for me (
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/SqlSchemaManagerImpl.java:
##########
@@ -178,6 +178,10 @@ private static IgniteSchema createSqlSchema(int
catalogVersion, CatalogSchemaDes
// Assemble indexes as they are required by tables.
for (CatalogIndexDescriptor indexDescriptor :
schemaDescriptor.indexes()) {
int tableId = indexDescriptor.tableId();
+ if (!indexDescriptor.available()) {
Review Comment:
seems we not need tableId if indexDescriptor.available() == true ) move this
check one line upper ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]