AMashenkov commented on code in PR #2518: URL: https://github.com/apache/ignite-3/pull/2518#discussion_r1312800174
########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java: ########## @@ -2017,52 +1993,81 @@ public CompletableFuture<TableImpl> tableImplAsync(String name) { /** * Gets a table by name, if it was created before. Doesn't parse canonical name. * - * @param name Table name. + * @param tableName Table name. * @return Future representing pending completion of the {@code TableManager#tableAsyncInternal} operation. */ - public CompletableFuture<TableImpl> tableAsyncInternal(String name) { + public CompletableFuture<TableImpl> tableAsyncInternal(String tableName) { if (!busyLock.enterBusy()) { throw new IgniteException(new NodeStoppingException()); } try { - return supplyAsync(() -> inBusyLock(busyLock, () -> directTableId(name)), ioExecutor) - .thenCompose(tableId -> inBusyLock(busyLock, () -> { + HybridTimestamp now = clock.now(); + + return schemaSyncService.waitForMetadataCompleteness(now) + .thenComposeAsync(ignore -> { + Integer tableId = tableNameToId(tableName); + if (tableId == null) { + // Table isn't configured. return completedFuture(null); } - return tableAsyncInternal(tableId, false); - })); + TableImpl table = latestTablesById().get(tableId); + + if (table != null) { + // Table was published. + return completedFuture(table); + } + + // Wait for table initialization. + return tableReadyFuture(tableId); + }, ioExecutor); } finally { busyLock.leaveBusy(); } } /** - * Internal method for getting table by id. + * Gets a table by id, if it was created before. * - * @param id Table id. - * @param checkConfiguration {@code True} when the method checks a configuration before trying to get a table, {@code false} - * otherwise. - * @return Future representing pending completion of the operation. + * @param tableId Table id. + * @return Future representing pending completion of the {@code TableManager#tableAsyncInternal} operation. */ - public CompletableFuture<TableImpl> tableAsyncInternal(int id, boolean checkConfiguration) { - CompletableFuture<Boolean> tblCfgFut = checkConfiguration - ? supplyAsync(() -> inBusyLock(busyLock, () -> isTableConfigured(id)), ioExecutor) - : completedFuture(true); + private CompletableFuture<TableImpl> tableAsyncInternal(int tableId) { + HybridTimestamp now = clock.now(); - return tblCfgFut.thenCompose(isCfg -> inBusyLock(busyLock, () -> { - if (!isCfg) { - return completedFuture(null); - } + return schemaSyncService.waitForMetadataCompleteness(now) Review Comment: What is the root cause? `ClusterTime.waitFor` registers a future and should cancel futures on close. This is the way all components must work - be responsible to cancel futures they returns. The fact, we do uninterruptible awaiting`future.join()` inside the busy lock due to no reason, shouldn't force us to write 'workarounds'. -- 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-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org