ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [07/50] ignite git commit: ignite-db - fixes
Date Thu, 28 Apr 2016 08:52:37 GMT
ignite-db - fixes


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

Branch: refs/heads/ignite-db-x-10884
Commit: d914e213a36029d9ee650f6f6936f55f470a6bfe
Parents: d7e35ee
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Thu Apr 21 01:18:19 2016 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Thu Apr 21 01:18:19 2016 +0300

----------------------------------------------------------------------
 .../cache/database/tree/BPlusTree.java          | 22 +++++++++++++-------
 1 file changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d914e213/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
index 61c49d7..1e72677 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java
@@ -432,7 +432,7 @@ public abstract class BPlusTree<L, T extends L> {
 
             Tail<L> t = r.getTail(lvl, false);
 
-            assert t.io == io : "must be the same"; // Otherwise may be not compatible.
+            assert t.io == io : "must be the same"; // Otherwise can be not compatible.
 
             return r.mergePages(prnt, t, fwd, fwdBuf) ? TRUE : FALSE;
         }
@@ -1204,9 +1204,13 @@ public abstract class BPlusTree<L, T extends L> {
             try {
                 BPlusIO<L> io = io(buf);
 
-                assert io.getCount(buf) > 0;
+                assert io.getCount(buf) >= 0; // Count can be 0 if it is a routing page.
 
-                return inner(io).getLeft(buf, 0);
+                long res = inner(io).getLeft(buf, 0);
+
+                assert res != 0: "inner page with no route down: " + page.fullId();
+
+                return res;
             }
             finally {
                 page.releaseRead();
@@ -1936,14 +1940,14 @@ public abstract class BPlusTree<L, T extends L> {
             // Remove found inner key from inner page.
             doRemove(inner.io, inner.page, inner.buf, cnt, inner.idx, inner.lvl, kickLeft);
 
-            // If inner page was root and became empty, it was freed in doRemove.
+            // If inner page was root and became empty, it was handled in doRemove.
             // Otherwise we can be sure that inner page was not freed, at lead it must become
             // an empty routing page. Thus always starting from inner.down here.
             for (Tail t = inner.down; t != null; t = t.down) {
                 if (t.fwd != null)
                     t = t.fwd;
 
-                assert t.io.getCount(t.buf) == 0;
+                assert t.io.getCount(t.buf) == 0: row;
 
                 freePage(t.page, t.buf, t.io, t.lvl);
             }
@@ -2051,21 +2055,23 @@ public abstract class BPlusTree<L, T extends L> {
                 }
             }
             else {
-                assert cur.io == back.io: "must always be the same"; // Otherwise may be
not compatible.
+                assert cur.io == back.io: "must always be the same"; // Otherwise can be
not compatible.
 
                 if (mergePages(prnt, back, cur.page, cur.buf)) {
                     assert prnt.down == back;
                     assert back.fwd == cur;
 
-                    // Back becomes current.
+                    // Back becomes current, current is dropped.
                     back.down = cur.down;
                     back.fwd = null;
 
+                    // Always unlock and release current because we made it invisible for
further code.
+                    writeUnlockAndClose(cur.page);
+
                     if (releaseMerged) {
                         prnt.down = null;
 
                         writeUnlockAndClose(back.page);
-                        writeUnlockAndClose(cur.page);
                     }
 
                     return true;


Mime
View raw message