BewareMyPower opened a new pull request, #16399:
URL: https://github.com/apache/pulsar/pull/16399

   ### Motivation
   
   `ManagedCursorImpl` maintains a field `waitingReadOp` as the cache of
   the `OpReadEntry` created in `asyncReadEntriesOrWait` when there are no
   more entries to read. However, there are two cases that the created
   `OpReadEntry` are not recycled:
   1. `asyncReadEntriesOrWait` is called repeatedly when `waitingReadOp` is
      not null and there are no more entries. The new created `OpReadEntry`
     cannot pass the CAS check but it's not recycled.
   2. `cancelPendingReadRequest` is called. The `waitingReadOp` is just set
      with null and the previous reference is not recycled.
   
   ### Modifications
   
   For the two cases described above, recycle the `OpReadEntry` objects.
   
   ### Verifying this change
   
   To verify all `OpReadEntry` are recycled correctly, this PRs adds two
   static atomic integers to record the create count and the recycle count.
   Then add `testOpReadEntryRecycle` to reproduce the corner cases and
   verify these counts.
   
   ### Documentation
   
   Check the box below or label this PR directly.
   
   Need to update docs? 
   
   - [ ] `doc-required` 
   (Your PR needs to update docs and you will update later)
     
   - [x] `doc-not-needed` 
   (Please explain why)
     
   - [ ] `doc` 
   (Your PR contains doc changes)
   
   - [ ] `doc-complete`
   (Docs have been already added)


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