JackieTien97 opened a new pull request, #18834:
URL: https://github.com/apache/iotdb/pull/18834
## Description
A delayed fragment cleanup can retain an old query-memory map while another
fragment removes the last registration and a later fragment creates a
replacement map. Removing the outer entry by query ID alone then deletes the
replacement, causing `MemoryPool.free()` to fail when buffered results are
consumed.
Only remove the outer entry when it still references the map being cleaned
up. The identity check stays inside the existing registration lock, while
memory-usage checks remain outside it.
Add a deterministic concurrent regression test that pauses an empty
fragment's cleanup at the registration lock, replaces the query map, and
verifies that the new reservation survives and can be freed. Additional tests
cover missing fragments, other active fragments, deferred and repeated cleanup,
and forced memory-leak reporting.
## Validation
- Before the production fix, the new concurrent test fails with
`expected:<1> but was:<0>` because the replacement registration is removed.
- English full-reactor build with focused unit tests passed:
`MemoryPoolTest` (27 tests) and `SharedTsBlockQueueTest` (2 tests).
- `mvn clean test -Dtest=MemoryPoolTest,SharedTsBlockQueueTest
-Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false`
- Chinese full-reactor compilation passed:
- `mvn test-compile -DskipTests -P with-zh-locale`
- `IoTDBTableViewQueryIT` passed all four aligned/flush combinations in a
clean worktree:
- `mvn clean verify -DskipUTs -Dit.test=IoTDBTableViewQueryIT
-DfailIfNoTests=false -Dfailsafe.failIfNoSpecifiedTests=false
-DDataNodeMaxHeapSize=1024 -DintegrationTest.forkCount=1 -pl integration-test
-am -P with-integration-tests -P TableSimpleIT`
- Spotless formatting and `git diff --check` passed.
## Checklist
- [x] Self-reviewed concurrent registration and deregistration.
- [x] Added comments explaining the identity check.
- [x] Added unit tests for the race and cleanup semantics.
- [x] Tested the affected query path in an IoTDB test cluster.
### Key changed classes
- `MemoryPool`
- `MemoryPoolTest`
--
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]