You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2019/03/27 15:35:54 UTC
[bookkeeper] branch master updated: Fix when met unexpect entry id
crashed
This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 6c3f33f Fix when met unexpect entry id crashed
6c3f33f is described below
commit 6c3f33f55fc3754925323b1d077108331d027aaf
Author: Yong Zhang <zh...@gmail.com>
AuthorDate: Wed Mar 27 23:35:48 2019 +0800
Fix when met unexpect entry id crashed
Fixes #2001
*Motivation*
When met a unexpect entry id, db indexes failed cleanup.
*Modifications*
Catch the exception and ignore it.
Master Issue: #2001
Reviewers: Jia Zhai <zh...@apache.org>, Matteo Merli <mm...@apache.org>
This closes #2002 from zymap/fixnoentryexception
---
.../bookie/storage/ldb/EntryLocationIndex.java | 10 ++++++-
.../bookie/storage/ldb/EntryLocationIndexTest.java | 32 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java
index 5673883..6b01c50 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndex.java
@@ -216,7 +216,15 @@ public class EntryLocationIndex implements Closeable {
}
long firstEntryId = ArrayUtil.getLong(firstKeyRes.getKey(), 8);
- long lastEntryId = getLastEntryInLedgerInternal(ledgerId);
+ long lastEntryId;
+ try {
+ lastEntryId = getLastEntryInLedgerInternal(ledgerId);
+ } catch (Bookie.NoEntryException nee) {
+ if (log.isDebugEnabled()) {
+ log.debug("No last entry id found for ledger {}", ledgerId);
+ }
+ continue;
+ }
if (log.isDebugEnabled()) {
log.debug("Deleting index for ledger {} entries ({} -> {})",
ledgerId, firstEntryId, lastEntryId);
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndexTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndexTest.java
index 6e83ffd..f1cefed 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndexTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/storage/ldb/EntryLocationIndexTest.java
@@ -23,6 +23,7 @@ package org.apache.bookkeeper.bookie.storage.ldb;
import static org.junit.Assert.assertEquals;
import java.io.File;
+import java.io.IOException;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.stats.NullStatsLogger;
@@ -108,4 +109,35 @@ public class EntryLocationIndexTest {
idx.close();
}
+
+ // test non exist entry
+ @Test
+ public void testDeleteSpecialEntry() throws IOException {
+ File tmpDir = File.createTempFile("bkTest", ".dir");
+ tmpDir.delete();
+ tmpDir.mkdir();
+ tmpDir.deleteOnExit();
+
+ EntryLocationIndex idx = new EntryLocationIndex(serverConfiguration, KeyValueStorageRocksDB.factory,
+ tmpDir.getAbsolutePath(), NullStatsLogger.INSTANCE);
+
+ // Add some dummy indexes
+ idx.addLocation(40312, -1, 1);
+ idx.addLocation(40313, 10, 2);
+ idx.addLocation(40320, 0, 3);
+
+ // Add more indexes in a different batch
+ idx.addLocation(40313, 11, 5);
+ idx.addLocation(40313, 12, 6);
+ idx.addLocation(40320, 1, 7);
+
+ // delete a non exist entry
+ idx.delete(40312);
+ idx.removeOffsetFromDeletedLedgers();
+
+ // another delete entry operation shouldn't effected
+ idx.delete(40313);
+ idx.removeOffsetFromDeletedLedgers();
+ assertEquals(0, idx.getLocation(40312, 10));
+ }
}