ivankelly closed pull request #645: Fix concurrent v2 reads on the same
ledger/entry
URL: https://github.com/apache/bookkeeper/pull/645
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
index dcc58f274..59510f5ff 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
@@ -726,9 +726,16 @@ private void readEntryInternal(final long ledgerId,
.build();
}
- completionObjects.put(completionKey,
- new ReadCompletion(completionKey, cb,
- ctx, ledgerId, entryId));
+ CompletionValue existingValue = completionObjects.putIfAbsent(
+ completionKey, new ReadCompletion(completionKey, cb,
+ ctx, ledgerId, entryId));
+ if (existingValue != null) {
+ // There's a pending read request on same ledger/entry. This is
not supported in V2 protocol
+ LOG.warn("Failing concurrent request to read at ledger: {} entry:
{}", ledgerId, entryId);
+
cb.readEntryComplete(BKException.Code.UnexpectedConditionException, ledgerId,
entryId, null, ctx);
+ return;
+ }
+
writeAndFlush(channel, completionKey, request);
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services