Skip to content

Commit

Permalink
GBPTree ConsistencyChecker include pointer in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Jan 16, 2018
1 parent a05f67a commit 63d1172
Showing 1 changed file with 19 additions and 11 deletions.
Expand Up @@ -390,6 +390,12 @@ private void assertSubtrees( PageCursor cursor, KeyRange<KEY> range, int keyCoun
do do
{ {
child = childAt( cursor, pos ); child = childAt( cursor, pos );
}
while ( cursor.shouldRetry() );
checkAfterShouldRetry( cursor );

do
{
childGeneration = node.pointerGeneration( cursor, child ); childGeneration = node.pointerGeneration( cursor, child );
} }
while ( cursor.shouldRetry() ); while ( cursor.shouldRetry() );
Expand Down Expand Up @@ -448,20 +454,22 @@ static void assertNoCrashOrBrokenPointerInGSPP( PageCursor cursor, long stableGe
long currentNodeId = cursor.getCurrentPageId(); long currentNodeId = cursor.getCurrentPageId();
// A // A
long generationA = GenerationSafePointer.readGeneration( cursor ); long generationA = GenerationSafePointer.readGeneration( cursor );
long pointerA = GenerationSafePointer.readPointer( cursor ); long readPointerA = GenerationSafePointer.readPointer( cursor );
long pointerA = GenerationSafePointerPair.pointer( readPointerA );
short checksumA = GenerationSafePointer.readChecksum( cursor ); short checksumA = GenerationSafePointer.readChecksum( cursor );
boolean correctChecksumA = GenerationSafePointer.checksumOf( generationA, pointerA ) == checksumA; boolean correctChecksumA = GenerationSafePointer.checksumOf( generationA, readPointerA ) == checksumA;
byte stateA = GenerationSafePointerPair.pointerState( byte stateA = GenerationSafePointerPair.pointerState(
stableGeneration, unstableGeneration, generationA, pointerA, correctChecksumA ); stableGeneration, unstableGeneration, generationA, readPointerA, correctChecksumA );
boolean okA = stateA != GenerationSafePointerPair.BROKEN && stateA != GenerationSafePointerPair.CRASH; boolean okA = stateA != GenerationSafePointerPair.BROKEN && stateA != GenerationSafePointerPair.CRASH;


// B // B
long generationB = GenerationSafePointer.readGeneration( cursor ); long generationB = GenerationSafePointer.readGeneration( cursor );
long pointerB = GenerationSafePointer.readPointer( cursor ); long readPointerB = GenerationSafePointer.readPointer( cursor );
long pointerB = GenerationSafePointerPair.pointer( readPointerA );
short checksumB = GenerationSafePointer.readChecksum( cursor ); short checksumB = GenerationSafePointer.readChecksum( cursor );
boolean correctChecksumB = GenerationSafePointer.checksumOf( generationB, pointerB ) == checksumB; boolean correctChecksumB = GenerationSafePointer.checksumOf( generationB, readPointerB ) == checksumB;
byte stateB = GenerationSafePointerPair.pointerState( byte stateB = GenerationSafePointerPair.pointerState(
stableGeneration, unstableGeneration, generationB, pointerB, correctChecksumB ); stableGeneration, unstableGeneration, generationB, readPointerB, correctChecksumB );
boolean okB = stateB != GenerationSafePointerPair.BROKEN && stateB != GenerationSafePointerPair.CRASH; boolean okB = stateB != GenerationSafePointerPair.BROKEN && stateB != GenerationSafePointerPair.CRASH;


if ( !(okA && okB) ) if ( !(okA && okB) )
Expand All @@ -471,15 +479,15 @@ static void assertNoCrashOrBrokenPointerInGSPP( PageCursor cursor, long stableGe
cursor.setCursorException( format( cursor.setCursorException( format(
"GSPP state found that was not ok in %s field in %s node with id %d%n slotA[%s]%n slotB[%s]", "GSPP state found that was not ok in %s field in %s node with id %d%n slotA[%s]%n slotB[%s]",
pointerFieldName, type, currentNodeId, pointerFieldName, type, currentNodeId,
stateToString( generationA, pointerA, stateA ), stateToString( generationA, readPointerA, pointerA, stateA ),
stateToString( generationB, pointerB, stateB ) ) ); stateToString( generationB, readPointerB, pointerB, stateB ) ) );
} }
} }


private static String stateToString( long generationA, long pointerA, byte stateA ) private static String stateToString( long generation, long readPointer, long pointer, byte stateA )
{ {
return format( "generation=%d, pointer=%d, state=%s", return format( "generation=%d, readPointer=%d, pointer=%d, state=%s",
generationA, pointerA, GenerationSafePointerPair.pointerStateName( stateA ) ); generation, readPointer, pointer, GenerationSafePointerPair.pointerStateName( stateA ) );
} }


private static class KeyRange<KEY> private static class KeyRange<KEY>
Expand Down

0 comments on commit 63d1172

Please sign in to comment.