This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new efc9cd3794d [fix](catalog) rebuild idToCatalog map after replay #43372
(#43837)
efc9cd3794d is described below
commit efc9cd3794d20a8aac3815e7e98b5ad0d134e41d
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Thu Nov 14 16:14:37 2024 +0800
[fix](catalog) rebuild idToCatalog map after replay #43372 (#43837)
cherry-pick #43372
---
.../main/java/org/apache/doris/datasource/CatalogMgr.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
index 93a4c1b19e6..91273736ebf 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/CatalogMgr.java
@@ -93,9 +93,9 @@ public class CatalogMgr implements Writable,
GsonPostProcessable {
private final MonitoredReentrantReadWriteLock lock = new
MonitoredReentrantReadWriteLock(true);
@SerializedName(value = "idToCatalog")
- private final Map<Long, CatalogIf<? extends DatabaseIf<? extends
TableIf>>> idToCatalog = Maps.newConcurrentMap();
+ private Map<Long, CatalogIf<? extends DatabaseIf<? extends TableIf>>>
idToCatalog = Maps.newConcurrentMap();
// this map will be regenerated from idToCatalog, so not need to persist.
- private final Map<String, CatalogIf> nameToCatalog =
Maps.newConcurrentMap();
+ private Map<String, CatalogIf> nameToCatalog = Maps.newConcurrentMap();
// Use a separate instance to facilitate access.
// internalDataSource still exists in idToCatalog and nameToCatalog
@@ -817,10 +817,17 @@ public class CatalogMgr implements Writable,
GsonPostProcessable {
@Override
public void gsonPostProcess() throws IOException {
+ // After deserializing from Gson, the concurrent map may become a
normal map.
+ // So here we reconstruct the concurrent map.
+ Map<Long, CatalogIf<? extends DatabaseIf<? extends TableIf>>>
newIdToCatalog = Maps.newConcurrentMap();
+ Map<String, CatalogIf> newNameToCatalog = Maps.newConcurrentMap();
for (CatalogIf catalog : idToCatalog.values()) {
- nameToCatalog.put(catalog.getName(), catalog);
+ newNameToCatalog.put(catalog.getName(), catalog);
+ newIdToCatalog.put(catalog.getId(), catalog);
// ATTN: can not call catalog.getProperties() here, because
ResourceMgr is not replayed yet.
}
+ this.idToCatalog = newIdToCatalog;
+ this.nameToCatalog = newNameToCatalog;
internalCatalog = (InternalCatalog)
idToCatalog.get(InternalCatalog.INTERNAL_CATALOG_ID);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]