Created
October 29, 2013 13:42
-
-
Save dejanb/7214853 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java | |
| index 0c269b4..bc914f1 100644 | |
| --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java | |
| +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java | |
| @@ -1086,7 +1086,21 @@ public class KahaDBStore extends MessageDatabase implements PersistenceAdapter { | |
| @Override | |
| public void checkpoint(boolean sync) throws IOException { | |
| - super.checkpointCleanup(sync); | |
| + try { | |
| + if (!opened.get()) { | |
| + load(); | |
| + } | |
| + super.checkpointCleanup(sync); | |
| + } catch (IOException ioe) { | |
| + try { | |
| + if (opened.get()) { | |
| + unload(); | |
| + } | |
| + } catch (Exception e) { | |
| + LOG.info("Exception closing the store", e); | |
| + } | |
| + throw ioe; | |
| + } | |
| } | |
| // ///////////////////////////////////////////////////////////////// | |
| diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java | |
| index b3c2d6f..b120da8 100644 | |
| --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java | |
| +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java | |
| @@ -415,11 +415,14 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe | |
| if( opened.compareAndSet(true, false)) { | |
| checkpointLock.writeLock().lock(); | |
| try { | |
| - if (metadata.page != null) { | |
| - checkpointUpdate(true); | |
| + try { | |
| + if (metadata.page != null) { | |
| + checkpointUpdate(true); | |
| + } | |
| + } finally { | |
| + pageFile.unload(); | |
| + metadata = new Metadata(); | |
| } | |
| - pageFile.unload(); | |
| - metadata = new Metadata(); | |
| } finally { | |
| checkpointLock.writeLock().unlock(); | |
| } | |
| @@ -1431,7 +1434,7 @@ public abstract class MessageDatabase extends ServiceSupport implements BrokerSe | |
| try { | |
| this.indexLock.writeLock().lock(); | |
| try { | |
| - pageFile.tx().execute(new Transaction.Closure<IOException>() { | |
| + getPageFile().tx().execute(new Transaction.Closure<IOException>() { | |
| @Override | |
| public void execute(Transaction tx) throws IOException { | |
| checkpointUpdate(tx, cleanup); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment