shuwenwei commented on PR #18999:
URL: https://github.com/apache/iotdb/pull/18999#issuecomment-6406569845

   ### Pipe aligned-chunk retry can reuse chunks already closed by a failed 
reader constructor
   
   In `TsFileInsertionEventScanParser.useNextPendingAlignedChunk()` (around 
L915-L943), the pending group is removed only after `AlignedChunkReader` / 
`AlignedSinglePageWholeChunkReader` is successfully constructed. If 
construction throws:
   
   - `AlignedChunkReader` closes the passed time/value chunks internally.
   - `AlignedSinglePageWholeChunkReader` explicitly calls `close()` in its 
constructor catch, closing the same value chunks.
   
   The pending group therefore still references value chunks whose page-AEAD 
references have already been released. If the exception is a classified 
memory-pressure exception, the code marks 
`shouldRetryChunkHeaderAfterMemoryPressure` and retries with that same closed 
group; otherwise later `clearCachedAlignedChunkData()` closes them again. This 
can both make the retry invalid and over-release the file crypto context.
   
   Suggested fix: do not leave the original borrowed chunk list in 
`pendingAlignedChunkGroups` after a reader constructor has taken ownership and 
failed. Either construct with independently retained chunks and only release 
that attempt's references on failure, or remove/reload the pending group before 
retry so it never reuses closed chunks or closes them a second time.
   


-- 
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]

Reply via email to