github-actions[bot] commented on code in PR #62064:
URL: https://github.com/apache/doris/pull/62064#discussion_r3031064648


##########
fe/fe-core/src/main/java/org/apache/doris/journal/bdbje/BDBEnvironment.java:
##########
@@ -312,21 +312,15 @@ public Database openDatabase(String dbName) {
     public void removeDatabase(String dbName) {
         lock.writeLock().lock();
         try {
-            String targetDbName = null;
-            int index = 0;
-            for (Database db : openedDatabases) {
+            for (java.util.Iterator<Database> iter = 
openedDatabases.iterator(); iter.hasNext();) {
+                Database db = iter.next();
                 String name = db.getDatabaseName();

Review Comment:
   `iter.remove()` fixes the index bookkeeping bug, but this line can still 
throw on a stale/preempted handle and abort the whole method. The same class 
already documents this exact `DatabasePreemptedException` case in 
`openDatabase()`.
   
   Concrete failure path: if `openedDatabases` contains a handle that was 
preempted by a replicated remove, `db.getDatabaseName()` throws here, 
`removeDatabase()` exits before calling 
`replicatedEnvironment.removeDatabase(null, dbName)`, and the old journal DB is 
not removed.
   
   Please mirror the stale-handle cleanup pattern from `openDatabase()` here 
(catch the exception, remove the stale entry, and continue scanning), and add a 
unit test that covers a preempted database handle in `openedDatabases`.



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