pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] rdhabalia closed pull request #2993: Handle unknown runtime exception while reading entries
Date Fri, 16 Nov 2018 08:01:46 GMT
rdhabalia closed pull request #2993: Handle unknown runtime exception while reading entries
URL: https://github.com/apache/pulsar/pull/2993
 
 
   

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/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/EntryCacheImpl.java
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/EntryCacheImpl.java
index ff80feccf6..a435c1442b 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/EntryCacheImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/EntryCacheImpl.java
@@ -162,6 +162,20 @@ public void invalidateAllEntries(long ledgerId) {
     @Override
     public void asyncReadEntry(ReadHandle lh, PositionImpl position, final ReadEntryCallback
callback,
             final Object ctx) {
+        try {
+            asyncReadEntry0(lh, position, callback, ctx);
+        } catch (Throwable t) {
+            log.warn("failed to read entries for {}-{}", lh.getId(), position, t);
+            // invalidate all entries related to ledger from the cache (it might happen if
entry gets corrupt
+            // (entry.data is already deallocate due to any race-condition) so, invalidate
cache and next time read from
+            // the bookie)
+            invalidateAllEntries(lh.getId());
+            callback.readEntryFailed(createManagedLedgerException(t), ctx);
+        }
+    }
+    
+    private void asyncReadEntry0(ReadHandle lh, PositionImpl position, final ReadEntryCallback
callback,
+            final Object ctx) {
         if (log.isDebugEnabled()) {
             log.debug("[{}] Reading entry ledger {}: {}", ml.getName(), lh.getId(), position.getEntryId());
         }
@@ -202,9 +216,23 @@ public void asyncReadEntry(ReadHandle lh, PositionImpl position, final
ReadEntry
     }
 
     @Override
-    @SuppressWarnings({ "unchecked", "rawtypes" })
     public void asyncReadEntry(ReadHandle lh, long firstEntry, long lastEntry, boolean isSlowestReader,
             final ReadEntriesCallback callback, Object ctx) {
+        try {
+            asyncReadEntry0(lh, firstEntry, lastEntry, isSlowestReader, callback, ctx);
+        } catch (Throwable t) {
+            log.warn("failed to read entries for {}--{}-{}", lh.getId(), firstEntry, lastEntry,
t);
+            // invalidate all entries related to ledger from the cache (it might happen if
entry gets corrupt
+            // (entry.data is already deallocate due to any race-condition) so, invalidate
cache and next time read from
+            // the bookie)
+            invalidateAllEntries(lh.getId());
+            callback.readEntriesFailed(createManagedLedgerException(t), ctx);
+        }
+    }
+    
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    private void asyncReadEntry0(ReadHandle lh, long firstEntry, long lastEntry, boolean
isSlowestReader,
+            final ReadEntriesCallback callback, Object ctx) {
         final long ledgerId = lh.getId();
         final int entriesToRead = (int) (lastEntry - firstEntry) + 1;
         final PositionImpl firstPosition = PositionImpl.get(lh.getId(), firstEntry);


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message