luoluoyuyu opened a new pull request, #19314: URL: https://github.com/apache/iotdb/pull/19314
## Problem With `IoTConsensusV2` data regions, deleting a region logs ```text WARN ... [pool-1-IoTDB-DAL-Serialize(group-N)-1] ...PageCacheDeletionBuffer$PersistTask - Interrupted when waiting for taking DeletionResource from blocking queue to serialize. ``` once per deleted region and without a stack trace. A suite that drops databases/tables therefore produces one WARN per deleted region (e.g. 1860 WARNs for 1860 region deletions). `StorageEngine.deleteDataRegion()` -> `DataRegion.deleteDALFolderAndClose()` called `DeletionResourceManager.getInstance()`, which is a `computeIfAbsent` and therefore created an empty manager even when nothing had ever registered a deletion. The constructor creates the DAL folder, allocates the deletion buffer and starts the persist thread, which immediately blocks on the empty deletion queue. `deleteDALFolderAndClose()` then closed the manager, and `close()` interrupts the idle persist thread with `shutdownNow()`, so the expected shutdown interrupt was logged as WARN. The manager is normally created lazily only when a pipe deletion arrives (`PipeInsertionDataNodeListener.listenToDeleteData`), so for a region without pipes this was a pure create-then-close cycle: DAL folder created and deleted within the same milliseconds, and the buffer/thread built only to be torn down. ## Fix - `DataRegion.deleteDALFolderAndClose()` now uses `DeletionResourceManager.closeAndRemoveDAL()`, which closes the manager only if it already exists (`getInstanceIfPresent()`, no `computeIfAbsent`) and always removes the region's DAL folder without creating a manager. - `PageCacheDeletionBuffer.persistDeletion()` logs the `take()` interruption at DEBUG when the buffer is already closed and all deletions are flushed. This also covers managers that do exist (a region that had pipe deletions): a genuine interruption, or a close that timed out with unflushed deletions, still logs at WARN. ## Behavior | Scenario | Before | After | | --- | --- | --- | | Delete a region with no pipe/DAL activity (IoTConsensusV2) | creates buffer + thread + DAL dir, closes them, logs 1 WARN | no manager created, DAL dir removed, no WARN | | Delete a region whose manager exists and is idle | WARN on the expected shutdown interrupt | closed as before, expected interrupt logged at DEBUG | | Unexpected interrupt, or close timed out with unflushed deletions | WARN | WARN (unchanged) | ## Tests New `DeletionResourceManagerTest`: - `testDeleteDALFolderDoesNotCreateManager`: a leftover DAL folder is removed and `getInstanceIfPresent()` stays null. - `testCloseExistingManagerRemovesItAndDALFolder`: an existing manager is closed, removed from the map and its DAL folder is deleted. - `testClosingIdleManagerDoesNotWarnOnExpectedInterrupt`: attaches a logback appender to `PageCacheDeletionBuffer`, closes an idle manager and asserts the expected shutdown interrupt is logged at DEBUG and not WARN. Verified to fail before the fix. Regression run: `DeletionResourceManagerTest`, `DeletionResourceTest`, `DeletionRecoverTest`, `PageCacheDeletionBufferTest`, `DataRegionTest`, `StorageEngineTest` — 72 tests, 0 failures (1 pre-existing skip). `mvn spotless:apply` applied. -- 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]
