activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6207
Date Fri, 11 Mar 2016 15:55:48 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.13.x 442fadac8 -> 3dc769d1f


https://issues.apache.org/jira/browse/AMQ-6207

Perform writes / sync in predicatable order first to the recovery file
and then into the main index file.
(cherry picked from commit b39ab7867c208a967090eff189594c2b06dafb34)


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/3dc769d1
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/3dc769d1
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/3dc769d1

Branch: refs/heads/activemq-5.13.x
Commit: 3dc769d1f66e50c96dec6d634e1a347a577e7725
Parents: 442fada
Author: Timothy Bish <tabish121@gmail.com>
Authored: Fri Mar 11 09:57:53 2016 -0500
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Fri Mar 11 10:55:39 2016 -0500

----------------------------------------------------------------------
 .../store/kahadb/disk/page/PageFile.java        | 57 ++++++++++----------
 1 file changed, 29 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/3dc769d1/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java
b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java
index 8c5f0fe..f126b65 100644
--- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java
+++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/page/PageFile.java
@@ -1048,12 +1048,13 @@ public class PageFile {
             this.checkpointLatch = null;
         }
 
-        Checksum checksum = new Adler32();
+        // First land the writes in the recovery file
         if (enableRecoveryFile) {
+            Checksum checksum = new Adler32();
+
             recoveryFile.seek(RECOVERY_FILE_HEADER_SIZE);
-        }
-        for (PageWrite w : batch) {
-            if (enableRecoveryFile) {
+
+            for (PageWrite w : batch) {
                 try {
                     checksum.update(w.getDiskBound(), 0, pageSize);
                 } catch (Throwable t) {
@@ -1063,36 +1064,36 @@ public class PageFile {
                 recoveryFile.write(w.getDiskBound(), 0, pageSize);
             }
 
-            writeFile.seek(toOffset(w.page.getPageId()));
-            writeFile.write(w.getDiskBound(), 0, pageSize);
-            w.done();
+            // Can we shrink the recovery buffer??
+            if (recoveryPageCount > recoveryFileMaxPageCount) {
+                int t = Math.max(recoveryFileMinPageCount, batch.size());
+                recoveryFile.setLength(recoveryFileSizeForPages(t));
+            }
+
+            // Record the page writes in the recovery buffer.
+            recoveryFile.seek(0);
+            // Store the next tx id...
+            recoveryFile.writeLong(nextTxid.get());
+            // Store the checksum for thw write batch so that on recovery we
+            // know if we have a consistent
+            // write batch on disk.
+            recoveryFile.writeLong(checksum.getValue());
+            // Write the # of pages that will follow
+            recoveryFile.writeInt(batch.size());
+
+            if (enableDiskSyncs) {
+                recoveryFile.sync();
+            }
         }
 
         try {
-            if (enableRecoveryFile) {
-                // Can we shrink the recovery buffer??
-                if (recoveryPageCount > recoveryFileMaxPageCount) {
-                    int t = Math.max(recoveryFileMinPageCount, batch.size());
-                    recoveryFile.setLength(recoveryFileSizeForPages(t));
-                }
-
-                // Record the page writes in the recovery buffer.
-                recoveryFile.seek(0);
-                // Store the next tx id...
-                recoveryFile.writeLong(nextTxid.get());
-                // Store the checksum for thw write batch so that on recovery we
-                // know if we have a consistent
-                // write batch on disk.
-                recoveryFile.writeLong(checksum.getValue());
-                // Write the # of pages that will follow
-                recoveryFile.writeInt(batch.size());
+            for (PageWrite w : batch) {
+                writeFile.seek(toOffset(w.page.getPageId()));
+                writeFile.write(w.getDiskBound(), 0, pageSize);
+                w.done();
             }
 
             if (enableDiskSyncs) {
-                // Sync to make sure recovery buffer writes land on disk..
-                if (enableRecoveryFile) {
-                    recoveryFile.sync();
-                }
                 writeFile.sync();
             }
         } finally {


Mime
View raw message