Skip to content

Commit

Permalink
Fixes a read mis-interpretation in SeekCursor
Browse files Browse the repository at this point in the history
where it would treat reading a node which wasn't a tree node as tree inconsistency
  • Loading branch information
tinwelint committed Jan 11, 2017
1 parent baf1e2c commit 572e03c
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,22 +425,22 @@ private void traverseDownToFirstLeaf() throws IOException
checkOutOfBounds( cursor );

// Act
if ( notSaneRead() )
if ( notSaneRead() && fullRead )
{
if ( !fullRead )
{
throw new TreeInconsistencyException( "Read inconsistent tree node %d%n" +
" nodeType:%d%n currentNodeGen:%d%n newGen:%d%n newGenGen:%d%n isInternal:%b%n" +
" keyCount:%d%n maxKeyCount:%d%n searchResult:%d%n pos:%d%n childId:%d%n childIdGen:%d",
cursor.getCurrentPageId(), nodeType, currentNodeGen, newGen, newGenGen,
isInternal, keyCount, maxKeyCount, searchResult, pos, pointerId, pointerGen );
}

prepareToStartFromRoot();
isInternal = true;
continue;
}

if ( !fullRead )
{
throw new TreeInconsistencyException( "Read inconsistent tree node %d%n" +
" nodeType:%d%n currentNodeGen:%d%n newGen:%d%n newGenGen:%d%n isInternal:%b%n" +
" keyCount:%d%n maxKeyCount:%d%n searchResult:%d%n pos:%d%n childId:%d%n childIdGen:%d",
cursor.getCurrentPageId(), nodeType, currentNodeGen, newGen, newGenGen,
isInternal, keyCount, maxKeyCount, searchResult, pos, pointerId, pointerGen );
}

if ( goToNewGen() )
{
continue;
Expand Down Expand Up @@ -527,24 +527,24 @@ public boolean next() throws IOException
checkOutOfBounds( cursor );

// Act
if ( notSaneRead() )
if ( notSaneRead() && fullRead )
{
if ( !fullRead )
{
throw new TreeInconsistencyException( "Read inconsistent tree node %d%n" +
" nodeType:%d%n currentNodeGen:%d%n newGen:%d%n newGenGen:%d%n" +
" keyCount:%d%n maxKeyCount:%d%n searchResult:%d%n pos:%d%n" +
" rightSibling:%d%n rightSiblingGen:%d",
cursor.getCurrentPageId(), nodeType, currentNodeGen, newGen, newGenGen,
keyCount, maxKeyCount, searchResult, pos, pointerId, pointerGen );
}

// This node has been reused for something else than a tree node. Restart seek from root.
prepareToStartFromRoot();
traverseDownToFirstLeaf();
continue;
}

if ( !fullRead )
{
throw new TreeInconsistencyException( "Read inconsistent tree node %d%n" +
" nodeType:%d%n currentNodeGen:%d%n newGen:%d%n newGenGen:%d%n" +
" keyCount:%d%n maxKeyCount:%d%n searchResult:%d%n pos:%d%n" +
" rightSibling:%d%n rightSiblingGen:%d",
cursor.getCurrentPageId(), nodeType, currentNodeGen, newGen, newGenGen,
keyCount, maxKeyCount, searchResult, pos, pointerId, pointerGen );
}

if ( !verifyFirstKeyInNodeIsExpectedAfterGoTo() )
{
continue;
Expand Down

0 comments on commit 572e03c

Please sign in to comment.