Skip to content

Commit 1865105

Browse files
committed
[fix](paimon) Keep write table cache coherent
### What problem does this PR solve? Issue Number: close apache#65086 Related PR: apache#67023 Problem Summary: Doris and Paimon maintain separate table caches. After a Doris metadata-cache miss, Paimon CachingCatalog could return the same stale table handle, leaving writes planned with outdated bucket, path, or table options. Invalidate the inner Paimon entry before every outer-cache reload and verify the invalidate-before-get ordering. ### Release note Ensure refreshed Paimon writes use current table metadata. ### Check List (For Author) - Test: Unit Test - Added cache reload ordering coverage; FE checkstyle passed. Final compilation and test execution are deferred until all forward-port picks are complete. - Behavior changed: Yes, Paimon table reloads no longer reuse stale inner-cache entries. - Does this need documentation: No
1 parent 28d406c commit 1865105

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonCatalogOps.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ public List<String> listTables(String databaseName) throws Catalog.DatabaseNotEx
303303
*/
304304
@Override
305305
public Table getTable(Identifier identifier) throws Catalog.TableNotExistException {
306+
// Doris owns the outer table-metadata cache and only reaches this method on an outer-cache
307+
// load. Paimon's CachingCatalog owns a second cache for the Table and its lower-level readers.
308+
// Invalidate that inner entry before reloading, otherwise REFRESH or outer-cache expiry can
309+
// immediately repopulate Doris with the same stale bucket, path, or table options.
310+
catalog.invalidateTable(identifier);
306311
Table table = catalog.getTable(identifier);
307312
Map<String, String> optionsForCopy = PaimonTableOptions.forCopy(tableOptions);
308313
return optionsForCopy.isEmpty() ? table : table.copy(optionsForCopy);

‎fe/fe-connector/fe-connector-paimon/src/test/java/org/apache/doris/connector/paimon/PaimonTableOptionsTest.java‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
import org.junit.jupiter.api.Test;
3030
import org.junit.jupiter.api.io.TempDir;
3131

32+
import java.lang.reflect.Proxy;
3233
import java.nio.file.Path;
34+
import java.util.ArrayList;
3335
import java.util.Collections;
3436
import java.util.HashMap;
3537
import java.util.Map;
@@ -273,6 +275,33 @@ public void catalogOpsGetTableIsUntouchedWithoutTableOptions(@TempDir Path wareh
273275
}
274276
}
275277

278+
@Test
279+
public void catalogOpsInvalidatesPaimonCacheBeforeReload() throws Exception {
280+
List<String> calls = new ArrayList<>();
281+
Table loaded = (Table) Proxy.newProxyInstance(
282+
Table.class.getClassLoader(), new Class<?>[] {Table.class},
283+
(proxy, method, args) -> null);
284+
Catalog catalog = (Catalog) Proxy.newProxyInstance(
285+
Catalog.class.getClassLoader(), new Class<?>[] {Catalog.class},
286+
(proxy, method, args) -> {
287+
if ("invalidateTable".equals(method.getName())) {
288+
calls.add("invalidate");
289+
return null;
290+
}
291+
if ("getTable".equals(method.getName())) {
292+
calls.add("get");
293+
return loaded;
294+
}
295+
return null;
296+
});
297+
298+
Table actual = new PaimonCatalogOps.CatalogBackedPaimonCatalogOps(catalog)
299+
.getTable(Identifier.create("db", "t"));
300+
301+
Assertions.assertSame(loaded, actual);
302+
Assertions.assertEquals(java.util.Arrays.asList("invalidate", "get"), calls);
303+
}
304+
276305
@Test
277306
public void createCatalogRejectsBadTableOption() {
278307
Map<String, String> props = new HashMap<>();

0 commit comments

Comments
 (0)