924060929 commented on code in PR #69501:
URL: https://github.com/apache/doris/pull/69501#discussion_r4358752233


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/ExternalDatabase.java:
##########
@@ -347,6 +350,42 @@ public Optional<T> getTableForReplay(long tableId) {
         return Optional.ofNullable(tables.getIfPresent(tableName));
     }
 
+    /**
+     * Captures only a shared base table with a matching retained names 
snapshot. Guard order is catalog DB,
+     * table names, then table object, matching incremental name/object 
publication. No remote load is performed.
+     */
+    public Optional<Runnable> observeTableLookup(ExternalTable table, Runnable 
invalidateMetadata) {
+        if (!initialized || 
extCatalog.shouldBypassSchemaCache(SessionContext.current())) {
+            return Optional.empty();
+        }
+        NameCacheValue names = getTableNamesValue(false);
+        if (names == null || 
!table.getRemoteName().equals(names.remoteNameOfLocalName(table.getName()))) {
+            return Optional.empty();
+        }
+        return extCatalog.observeDatabase(this).flatMap(database ->
+                tableNames.observe("", names).flatMap(membership ->
+                        tables.observe(table.getName(), table).map(object -> 
() -> MetaCacheCleanup.runDeferred(() -> {
+                            // Catalog reset/connector replacement holds this 
monitor too. Only local invalidation
+                            // runs here; remote reads happened before 
entering this guarded commit.
+                            synchronized (extCatalog) {
+                                if (!initialized || !extCatalog.isInitialized()
+                                        || 
Env.getCurrentEnv().getCatalogMgr().getCatalog(extCatalog.getId())
+                                                != extCatalog) {
+                                    return;
+                                }
+                                database.runIfCurrent(() -> 
membership.invalidateIfCurrent(() ->

Review Comment:
   Fixed in bee05669e8b. Metadata-only refresh now advances a transient 
generation on the retained table object. Missing-table cleanup compares the 
captured generation while holding the same catalog monitor used to advance it, 
so a delayed missing response cannot evict metadata refreshed after its lookup 
began. Added a delayed-miss/metadata-refresh interleaving test that verifies 
the schema, name snapshot, object, ID, and connector cache remain intact. The 
scoped FE tests pass.



##########
fe/fe-connector/fe-connector-paimon/src/test/java/org/apache/doris/connector/paimon/PaimonConnectorMetadataReadAuthTest.java:
##########
@@ -156,8 +156,8 @@ public void getTableHandleRunsSeamInsideAuthenticator() {
         RecordingPaimonCatalogOps ops = new RecordingPaimonCatalogOps();
         RecordingConnectorContext ctx = new RecordingConnectorContext();
         ctx.failAuth = true;
-        Optional<ConnectorTableHandle> result = metadata(ops, 
ctx).getTableHandle(null, "db1", "t1");
-        Assertions.assertFalse(result.isPresent());
+        Assertions.assertThrows(DorisConnectorException.class,

Review Comment:
   Fixed in bee05669e8b. Removed the unused ConnectorTableHandle and Optional 
imports. The Paimon read-auth test class passes (12 tests), and the Maven 
Checkstyle validation completed successfully.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to