djsweet opened a new pull request, #4896:
URL: https://github.com/apache/bookkeeper/pull/4896

   Descriptions of the changes in this PR:
   
   <!-- Either this PR fixes an issue, -->
   
   Fixes #4895.
   
   ### Motivation
   
   `getLastEntry` in `EntryMemTable` could return incorrect results if metadata 
(entries with negative entry IDs) is in use for the ledger. The `KeyComparator` 
used within `EntryMemTable` uses a simple subtraction for comparison, and when 
`Long.MAX_VALUE` was compared against a negative value (e.g. an explicit LAC 
entry), this would result in a long overflow, and incorrect comparison results.
   
   ### Changes
   
   The proposed fix here is to ensure that the comparison within `getLastEntry` 
does not ever hit an integer overflow condition, by having the `floorKey` 
comparison occur against a long value that can accommodate subtracting the 
lowest possible metadata ID (a subtraction of a negative value, ultimately 
becoming an addition) so that a long overflow does not occur.
   
   This does reduce the highest possible entry ID within `EntryMemTable` by 
32,768 as of this commit, but it seems incredibly unlikely that real world 
BookKeeper clusters will see entry IDs close to 2^64.


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