Caideyipi commented on code in PR #19321:
URL: https://github.com/apache/iotdb/pull/19321#discussion_r4623399378


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/consensus/deletion/DeletionResourceManager.java:
##########
@@ -176,7 +176,26 @@ public List<DeletionResource> getAllDeletionResources() {
     }
   }
 
-  public void removeDAL() {
+  /** Close an existing manager and remove its DAL without creating a manager 
for cleanup. */
+  public static void closeAndRemoveDAL(int groupId) {
+    if (DeletionResourceManagerHolder.CONSENSUS_GROUP_ID_2_INSTANCE_MAP == 
null) {
+      return;
+    }
+    final DeletionResourceManager manager =
+        
DeletionResourceManagerHolder.CONSENSUS_GROUP_ID_2_INSTANCE_MAP.get(groupId);
+    if (manager != null) {
+      manager.close();
+      removeDAL(groupId, manager.storageDir);
+    } else {
+      removeDAL(

Review Comment:
   getInstance() builds the manager inside ConcurrentHashMap.computeIfAbsent(), 
and the entry is not visible until initAndRecover() returns. If region deletion 
reaches this helper while that initialization is in flight, get() returns null 
here and this branch deletes the directory the constructor is recovering; it 
can then finish with a live buffer pointing at a deleted DAL. Please serialize 
cleanup with per-region manager creation (and cover this overlap in a 
regression test) before deleting the directory.



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

Reply via email to