You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2019/11/12 01:35:37 UTC

[incubator-doris] branch master updated: Fix DB meta lost bug 2 (#2174)

This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new b4d6301  Fix DB meta lost bug 2 (#2174)
b4d6301 is described below

commit b4d630137ab130cac6c94f8be3de6c2e26470e41
Author: kangkaisen <ka...@apache.org>
AuthorDate: Tue Nov 12 09:35:27 2019 +0800

    Fix DB meta lost bug 2 (#2174)
---
 .../java/org/apache/doris/catalog/Catalog.java     | 35 ++++++++++++++--------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/fe/src/main/java/org/apache/doris/catalog/Catalog.java b/fe/src/main/java/org/apache/doris/catalog/Catalog.java
index cb945ab..f45a2ed 100644
--- a/fe/src/main/java/org/apache/doris/catalog/Catalog.java
+++ b/fe/src/main/java/org/apache/doris/catalog/Catalog.java
@@ -545,6 +545,10 @@ public class Catalog {
         return tabletChecker;
     }
 
+    public ConcurrentHashMap<String, Database> getFullNameToDb() {
+        return fullNameToDb;
+    }
+
     // use this to get correct ClusterInfoService instance
     public static SystemInfoService getCurrentSystemInfo() {
         return getCurrentCatalog().getClusterInfo();
@@ -1843,7 +1847,7 @@ public class Catalog {
             Database db = entry.getValue();
             String dbName = db.getFullName();
             // Don't write information_schema db meta
-            if (!dbName.endsWith(InfoSchemaDb.DATABASE_NAME)) {
+            if (!InfoSchemaDb.isInfoSchemaDb(dbName)) {
                 checksum ^= entry.getKey();
                 db.readLock();
                 try {
@@ -5739,20 +5743,25 @@ public class Catalog {
                 // for adding BE to some Cluster, but loadCluster is after loadBackend.
                 cluster.setBackendIdList(latestBackendIds);
 
-                String dbName = ClusterNamespace.getFullName(cluster.getName(), InfoSchemaDb.DATABASE_NAME);
-                if (!fullNameToDb.containsKey(dbName)) {
-                    final InfoSchemaDb db = new InfoSchemaDb(cluster.getName());
+                String dbName =  InfoSchemaDb.getFullInfoSchemaDbName(cluster.getName());
+                InfoSchemaDb db;
+                // Use real Catalog instance to avoid InfoSchemaDb id continuously increment
+                // when checkpoint thread load image.
+                if (Catalog.getInstance().getFullNameToDb().containsKey(dbName)) {
+                    db = (InfoSchemaDb)Catalog.getInstance().getFullNameToDb().get(dbName);
+                } else {
+                    db = new InfoSchemaDb(cluster.getName());
                     db.setClusterName(cluster.getName());
-                    String errMsg = "InfoSchemaDb id shouldn't larger than 10000, please restart your FE server";
-                    // Every time we construct the InfoSchemaDb, which id will increment.
-                    // When InfoSchemaDb id larger than 10000 and put it to idToDb,
-                    // which may be overwrite the normal db meta in idToDb,
-                    // so we ensure InfoSchemaDb id less than 10000.
-                    Preconditions.checkState(db.getId() < NEXT_ID_INIT_VALUE, errMsg);
-                    idToDb.put(db.getId(), db);
-                    fullNameToDb.put(db.getFullName(), db);
                 }
-                cluster.addDb(dbName, fullNameToDb.get(dbName).getId());
+                String errMsg = "InfoSchemaDb id shouldn't larger than 10000, please restart your FE server";
+                // Every time we construct the InfoSchemaDb, which id will increment.
+                // When InfoSchemaDb id larger than 10000 and put it to idToDb,
+                // which may be overwrite the normal db meta in idToDb,
+                // so we ensure InfoSchemaDb id less than 10000.
+                Preconditions.checkState(db.getId() < NEXT_ID_INIT_VALUE, errMsg);
+                idToDb.put(db.getId(), db);
+                fullNameToDb.put(db.getFullName(), db);
+                cluster.addDb(dbName, db.getId());
                 idToCluster.put(cluster.getId(), cluster);
                 nameToCluster.put(cluster.getName(), cluster);
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org