Repository navigation
[fix][ml] OOM caused by orphan items in ActiveManagedCursorContainerImpl.pendingPositionUpdates - #26506
[fix][ml] OOM caused by orphan items in ActiveManagedCursorContainerImpl.pendingPositionUpdates#26506poorbarcode wants to merge 1 commit into
Conversation
| cursorRemovedTimestampMillis = System.currentTimeMillis(); | ||
| cursorCount--; | ||
| // Clear meaningless pending update, which avoids OOM. | ||
| if (meaninglessPendingUpdateCount >= 10) { |
There was a problem hiding this comment.
10 times, how to balance this value?
|
@poorbarcode Thanks for pinpointing the issue! However, the approach taken in this PR introduces additional position flushes in |
Motivation
The issue was introduced by #24623, only affects the version newer than
4.1.0Background
ActiveManagedCursorContainerImpltraces the slowest position of cursors.ActiveManagedCursorContainerImplmaintains two collections:pendingRemovedCursorsandpendingPositionUpdates.pendingRemovedCursorscaches the events that cursors are inactive, andpendingPositionUpdatescaches the events that cursors are active.pendingRemovedCursorsandpendingPositionUpdates.Issue
With
cacheEvictionByExpectedReadCountenabled, a cursor can be removed before its read any messages. The removed cursor is no longer tracked in the Managed ledger, but its node remains inActiveManagedCursorContainerImpl.pendingPositionUpdatesuntil a future pending-position flush. If no such flush is triggered, repeated cursor creation and removal can accumulate stale nodes and retain their associated cursor objects, increasing memory usage and potentially causing OOM.It can be reproduced with the following steps. See also the new test.
ActiveManagedCursorContainerImpl.pendingPositionUpdates.ActiveManagedCursorContainerImpl.pendingPositionUpdates.Modifications
Count orphan items in
ActiveManagedCursorContainerImpl.pendingPositionUpdates, flush pending cursor updates, and reset the counter when the count of orphan items is 10.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes