Caideyipi commented on code in PR #19314:
URL: https://github.com/apache/iotdb/pull/19314#discussion_r4610130193
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/consensus/deletion/DeletionResourceManager.java:
##########
@@ -308,6 +296,42 @@ public static DeletionResourceManager getInstance(int
groupId) {
});
}
+ /**
+ * Returns the manager of the given data region without creating one.
Deleting a data region must
+ * not create a manager just to close it, which would allocate a deletion
buffer and start a
+ * persist thread only to shut it down immediately.
+ */
+ public static DeletionResourceManager getInstanceIfPresent(int groupId) {
+ return DeletionResourceManagerHolder.CONSENSUS_GROUP_ID_2_INSTANCE_MAP ==
null
+ ? null
+ :
DeletionResourceManagerHolder.CONSENSUS_GROUP_ID_2_INSTANCE_MAP.get(groupId);
+ }
+
+ /** Closes the manager of the data region if it exists, then removes its DAL
folder. */
+ public static void closeAndRemoveDAL(int dataRegionId) {
+ DeletionResourceManager manager = getInstanceIfPresent(dataRegionId);
Review Comment:
Please serialize this lookup/close/remove operation with `getInstance()`.
`getInstanceIfPresent()` is only a point-in-time read: if a concurrent
`getInstance(dataRegionId)` creates and registers a manager after this returns
`null` but before `removeDALFolder`, this call skips `manager.close()` and
deletes the new manager DAL files while leaving its persist thread and map
entry alive. This is reachable from
`PipeHistoricalDataRegionTsFileAndDeletionSource.start()`, which can obtain the
`DataRegion` reference before deletion and call `getInstance()` under
`writeLock()`; `writeLock()` does not check `deleted`, so a caller queued
behind `markDeleted()` can still proceed. Please coordinate manager creation
with region teardown or prevent new creation before folder removal.
--
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]