lhotari commented on code in PR #4306:
URL: https://github.com/apache/bookkeeper/pull/4306#discussion_r1603211147


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java:
##########
@@ -480,8 +480,12 @@ public long addEntry(ByteBuf entry) throws IOException, 
BookieException {
         long stamp = writeCacheRotationLock.tryOptimisticRead();
         boolean inserted = false;
 
-        inserted = writeCache.put(ledgerId, entryId, entry);
-        if (!writeCacheRotationLock.validate(stamp)) {
+        // If the stamp is 0, the lock was exclusively acquired, validation 
will fail, and we can skip this put.

Review Comment:
   I think it's better to just use the StampedLock API to do that validation. 
It's not an expensive operation.



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