kangkaisen commented on a change in pull request #2167: Fix DB meta lost bug
URL: https://github.com/apache/incubator-doris/pull/2167#discussion_r344533747
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/catalog/Catalog.java
 ##########
 @@ -5738,11 +5739,17 @@ public long loadCluster(DataInputStream dis, long 
checksum) throws IOException,
                 // for adding BE to some Cluster, but loadCluster is after 
loadBackend.
                 cluster.setBackendIdList(latestBackendIds);
 
-                final InfoSchemaDb db = new InfoSchemaDb(cluster.getName());
-                db.setClusterName(cluster.getName());
-                idToDb.put(db.getId(), db);
-                fullNameToDb.put(db.getFullName(), db);
-                cluster.addDb(db.getFullName(), db.getId());
+                String dbName = 
ClusterNamespace.getFullName(cluster.getName(), InfoSchemaDb.DATABASE_NAME);
+                if (!fullNameToDb.containsKey(dbName)) {
+                    final InfoSchemaDb db = new 
InfoSchemaDb(cluster.getName());
+                    db.setClusterName(cluster.getName());
+                    String errMsg = "InfoSchemaDb id shouldn't larger than 
10000, please restart your FE server";
+                    // ensure InfoSchemaDb meta don't overwrite the normal db 
meta
+                    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());
 
 Review comment:
   > So the problem is that if we create more than 10000 clusters, this may 
still be a problem? However it is almost impossible to happen.
   
   Yes. I also considered this problem.  I think cluster will be obsolete after 
https://github.com/apache/incubator-doris/issues/1723, so I don't add a check 
when create cluster.
   
   If you think the check is necessary, I could add a check.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to