BewareMyPower opened a new pull request #2832:
URL: https://github.com/apache/bookkeeper/pull/2832


   ### Motivation
   
   If `EntryMemTable#addEntry` accepts the same entries (assuming size is `N`), 
which means they have the same ledger id and entry id, the semaphore will be 
acquired multiple times (assuming `M` times) but only one entry will be added 
to `kvmap`. When the `EntryMemTable` is flushed, only `N` permits will be 
released, while `M * N` permits are acquired.  Then the semaphore leak happens.
   
   ### Changes
   
   In `EntryMemTable#addEntry`, release the acquired permits if `internalAdd` 
returns 0. Because it means the entry size is zero or the entry has already 
existed in `kvmap`. `testAddSameEntries` is added to verify when the same 
entries are added, `flush` can still release all acquired permits.


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