Pengzna commented on PR #19321: URL: https://github.com/apache/iotdb/pull/19321#issuecomment-7006069859
@luoluoyuyu Thanks for the detailed review. I agreed that the original patch left a lifecycle race, and revised the implementation in dd1a1211842c123403a125f088ece4b72ba106c2: 1. **Creation/cleanup ownership:** manager creation, registration, ordinary close, reference-release cleanup and close-and-remove now share a stable region lifecycle lock. Region deletion installs a tombstone before stopping producers, and close-and-remove keeps the lock through directory removal. Late get-or-create returns null, a retained closed/deleted manager returns a failed persistence result, and old-manager callbacks cannot touch a new lifecycle's DAL. Only the storage region-creation path clears the tombstone. The assigner and historical event-binding lookups now use `getInstanceIfPresent`; historical recovery and the local-deletion producer retain lazy creation where needed, behind the barrier. Historical extraction also checks the DataRegion's deleted state under its write lock. 2. **Shutdown:** initial queue waiting and batch collection use bounded polls that observe close. After accepted deletions drain, the executor uses `shutdown()` and exits naturally. The existing forced-shutdown fallback remains after a flush timeout, with an explicit WARN reporting the outstanding count; unexpected interruptions still warn. The batch-poll message now refers to DeletionResource rather than WALEntry. 3. **Ordering:** `StorageEngine.deleteDataRegion` first installs the DAL creation barrier, releases the receiver, and removes/drains the realtime assigner; it then closes the manager and removes DAL. Late listener registration is blocked until a new storage lifecycle starts. Producer shutdown runs without holding the DAL lock. I also moved the atomic reference-release hook outside the DeletionResource monitor to avoid lock inversion with persistence callbacks during close. Added latch-controlled tests for initialization overlapping cleanup and creation attempting to enter between close and directory removal, plus coverage for late creation/registration, old callbacks after recreation, StorageEngine cleanup order, stopped listener admission, idle/batch shutdown, unexpected interruption and flush timeout. Validation: JDK 17, all **33 tests** in the six relevant classes passed with 0 failures/errors. Spotless and English/Chinese compilation passed through DataNode, ConfigNode and upstream modules. Both root reactor runs stopped later at `distribution` because the local server/CLI/ConfigNode 2.0.13-SNAPSHOT zip artifacts are absent, so I am not claiming a complete reactor build. No local cluster IT was run; CI for the new commit is in progress. -- 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]
