You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/02/28 11:20:10 UTC

[GitHub] [ignite-3] korlov42 commented on a change in pull request #692: IGNITE-16558 Sql schema synchronization

korlov42 commented on a change in pull request #692:
URL: https://github.com/apache/ignite-3/pull/692#discussion_r815784296



##########
File path: modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/SqlSchemaManagerImpl.java
##########
@@ -72,33 +72,43 @@ public SchemaPlus schema(@Nullable String schema) {
     /** {@inheritDoc} */
     @Override
     @NotNull
-    public IgniteTable tableById(UUID id) {
+    public IgniteTable tableById(UUID id, int ver) {
         IgniteTable table = tablesById.get(id);
 
         // there is a chance that someone tries to resolve table before
         // the distributed event of that table creation has been processed
         // by TableManager, so we need to get in sync with the TableManager
-        if (table == null) {
-            ensureTableStructuresCreated(id);
-
-            // at this point the table is either null means no such table
-            // really exists or the table itself
-            table = tablesById.get(id);
+        if (table == null || ver > table.version()) {
+            table = awaitLatestTableSchema(id);
         }
 
         if (table == null) {
             throw new IgniteInternalException(
                     IgniteStringFormatter.format("Table not found [tableId={}]", id));
         }
 
+        if (table.version() < ver) {
+            throw new IgniteInternalException(
+                    IgniteStringFormatter.format("Table version not found [tableId={}, requiredVer={},  latestKnownVer={}]",

Review comment:
       > Should we use different exceptions
   
   I agree that "Table version not found" is more like `IllegalStateException`, but currently they both will be handled in the same way. With that said, do we really need a separate exception right now?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org