Skip to content

fix: memory leak during tvlist owner transfer scenario#16932

Merged
JackieTien97 merged 4 commits intoapache:masterfrom
shizy818:fix_tvlist_owner
Dec 22, 2025
Merged

fix: memory leak during tvlist owner transfer scenario#16932
JackieTien97 merged 4 commits intoapache:masterfrom
shizy818:fix_tvlist_owner

Conversation

@shizy818
Copy link
Contributor

@shizy818 shizy818 commented Dec 19, 2025

Description

Steps to reproduce the issue:

  1. During flushing, the TVList is accessed by Query 1. FragmentInstanceContext of Query 1 calls reserveMemoryCumulatively to reserve memory. Query 1 is added into TVList's query set and be set as owner.
  2. Query 2 access the TVList as well and is added into TVList's query set.
  3. When Query 1 terminates, it should transfers the ownership of the TVList to Query 2. FragmentInstanceContext of Query 1 calls releaseMemoryReservationManager to release memory.
  4. When Query 2 terminates, FragmentInstanceContext calls releaseMemoryCumulatively to release memory because Query 2 is the last query and be the owner.

Release operation is invoked twice. This PR is to transfer momery virtually from MemoryReservationManager of Query 1 to that of Query 2 without actually allocating/freeing the memory.

* reservedBytesInTotal >= size to ensure proper memory accounting and prevent negative
* reservation values.
*/
Pair<Long, Long> releaseMemoryVirtually(final long size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add some java doc about the return value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@JackieTien97 JackieTien97 merged commit 7722963 into apache:master Dec 22, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants