Harden query memory reservation deregistration ordering#18272
Harden query memory reservation deregistration ordering#18272Caideyipi wants to merge 2 commits into
Conversation
|
Could you clarify which production interleaving this test is intended to reproduce? The failure log only proves that |
|
Good catch. I audited the production lifecycle and agree that the original description overstated what the failure log proves. In the normal FI terminal path, sink/driver/source cleanup happens before deregistration, and pending reservations are cancelled or completed under the future lock. I did not find a concrete normal-path caller that starts a new reservation after FI cleanup. I addressed the actionable reverse ordering in 7af40af:
I also revised the PR title/description to distinguish this defensive hardening from the still-unproven production interleaving. Verification passed: |
Description
A table standalone integration test exposed this failure at the query-memory boundary:
The failure proves that a free reached
MemoryPoolafter deregistration. It does not by itself prove that a new reservation raced with FI deregistration.After auditing the production FI terminal path, the normal ordering is:
clearShuffleSinkHandle();driver.close();releaseResourceWhenAllDriversAreClosed();MemoryPool.Handle cleanup also cancels or completes pending reservation futures under the same future lock used when
MemoryPool.free()grants them. I did not find a concrete normal-path caller that starts a new reservation after FI cleanup. The change below is therefore defensive hardening of theMemoryPoolAPI boundary; it does not claim that the failure log demonstrates a production reserve/deregister race.This is independent of the Pipe changes in #18266. That PR's head was based directly on
b8ff9eeaea0d2e5afd79446e8bb4cf654c8c8038and touched onlyPipeMemoryManagerand its test.Fix
IllegalArgumentExceptionbefore allocating or releasing memory instead of retrying into a null dereference.Tests
Added deterministic coverage for both lock orderings:
Executed:
mvn spotless:apply -pl iotdb-core/datanodemvn -o -nsu '-Ddevelocity.off=true' test -pl iotdb-core/datanode '-Dtest=MemoryPoolTest'mvn -o -nsu '-Ddevelocity.off=true' test-compile -pl iotdb-core/datanode -P with-zh-locale '-DskipTests'This PR has: