Merge branch 'ignite-4652' of https://github.com/svladykin/ignite into ignite-4652
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e03af959 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e03af959 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e03af959 Branch: refs/heads/ignite-4652 Commit: e03af959c53416ed830f1c1cab3618cf20a6e654 Parents: 8b68231 00820a9 Author: Sergi Vladykin <[email protected]> Authored: Thu Feb 16 15:03:03 2017 +0300 Committer: Sergi Vladykin <[email protected]> Committed: Thu Feb 16 15:03:03 2017 +0300 ---------------------------------------------------------------------- .../cache/database/tree/BPlusTree.java | 903 ++++++++++++++----- .../processors/database/BPlusTreeSelfTest.java | 153 +++- 2 files changed, 807 insertions(+), 249 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/e03af959/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java index cdceffb,20860f5..c1589a6 --- 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 @@@ -362,18 -355,27 +355,29 @@@ public abstract class BPlusTree<L, T ex // Get old row in leaf page to reduce contention at upper level. p.oldRow = p.needOld ? getRow(io, pageAddr, idx) : (T)Boolean.TRUE; - p.finish(); - // Inner replace state must be consistent by the end of the operation. assert p.needReplaceInner == FALSE || p.needReplaceInner == DONE : p.needReplaceInner; + + // Need to replace inner key if now we are replacing the rightmost row and have a forward page. + if (canGetRowFromInner && idx + 1 == cnt && p.fwdId != 0L && p.needReplaceInner == FALSE) { + // Can happen only for invoke, otherwise inner key must be replaced on the way down. + assert p.invoke; + + // We need to restart the operation from root to perform inner replace. + // On the second pass we will not get here (will avoid infinite loop) because + // needReplaceInner will be DONE or our key will not be the rightmost anymore. + return RETRY_ROOT; + } + else + p.finish(); } - io.store(pageAddr, idx, newRow, null); + boolean needWal = needWalDeltaRecord(page); - if (needWalDeltaRecord(page)) - wal.log(new ReplaceRecord<>(cacheId, page.id(), io, newRow, null, idx)); + byte[] newRowBytes = io.store(pageAddr, idx, newRow, null, needWal); + + if (needWal) + wal.log(new ReplaceRecord<>(cacheId, page.id(), io, newRowBytes, idx)); return FOUND; } http://git-wip-us.apache.org/repos/asf/ignite/blob/e03af959/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java ----------------------------------------------------------------------
