public static PageCorruption <KEY, VALUE> SetPointer <KEY, VALUE>(GBPTreePointerType pointerType, long pointer) { return((cursor, layout, node, treeState) => { OverwriteGSPP(cursor, pointerType.Offset(node), treeState.stableGeneration(), pointer); }); }
public static PageCorruption <KEY, VALUE> Broken <KEY, VALUE>(GBPTreePointerType gbpTreePointerType) { return((pageCursor, layout, node, treeState) => { int offset = gbpTreePointerType.Offset(node); pageCursor.Offset = offset; pageCursor.putInt(int.MaxValue); }); }
public static PageCorruption <KEY, VALUE> SetChild <KEY, VALUE>(int childPos, long childPointer) { return((cursor, layout, node, treeState) => { GenerationKeeper childGeneration = new GenerationKeeper(); node.childAt(cursor, childPos, treeState.stableGeneration(), treeState.unstableGeneration(), childGeneration); OverwriteGSPP(cursor, GBPTreePointerType.child(childPos).offset(node), childGeneration.Generation, childPointer); }); }
/* PageCorruption */ public static PageCorruption <KEY, VALUE> Crashed <KEY, VALUE>(GBPTreePointerType gbpTreePointerType) { return((pageCursor, layout, node, treeState) => { int offset = gbpTreePointerType.Offset(node); long stableGeneration = treeState.stableGeneration(); long unstableGeneration = treeState.unstableGeneration(); long crashGeneration = crashGeneration(treeState); pageCursor.Offset = offset; long pointer = pointer(GenerationSafePointerPair.Read(pageCursor, stableGeneration, unstableGeneration, NO_GENERATION_TARGET)); OverwriteGSPP(pageCursor, offset, crashGeneration, pointer); }); }
public static PageCorruption <KEY, VALUE> SwapChildOrder <KEY, VALUE>(int firstChildPos, int secondChildPos, int keyCount) { return((cursor, layout, node, treeState) => { // Read first and second child together with generation GenerationKeeper firstChildGeneration = new GenerationKeeper(); long firstChild = node.childAt(cursor, firstChildPos, treeState.stableGeneration(), treeState.unstableGeneration(), firstChildGeneration); GenerationKeeper secondChildGeneration = new GenerationKeeper(); long secondChild = node.childAt(cursor, secondChildPos, treeState.stableGeneration(), treeState.unstableGeneration(), secondChildGeneration); // Overwrite respective child with the other OverwriteGSPP(cursor, GBPTreePointerType.child(firstChildPos).offset(node), secondChildGeneration.Generation, secondChild); OverwriteGSPP(cursor, GBPTreePointerType.child(secondChildPos).offset(node), firstChildGeneration.Generation, firstChild); }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCleanMultipleCrashPerPage() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCleanMultipleCrashPerPage() { // GIVEN Page[] pages = With(LeafWith(GBPTreeCorruption.Crashed(GBPTreePointerType.leftSibling()), GBPTreeCorruption.Crashed(GBPTreePointerType.rightSibling()), GBPTreeCorruption.Crashed(GBPTreePointerType.successor())), InternalWith(GBPTreeCorruption.Crashed(GBPTreePointerType.leftSibling()), GBPTreeCorruption.Crashed(GBPTreePointerType.rightSibling()), GBPTreeCorruption.Crashed(GBPTreePointerType.successor()), GBPTreeCorruption.Crashed(GBPTreePointerType.child(0)))); InitializeFile(_pagedFile, pages); // WHEN SimpleCleanupMonitor monitor = new SimpleCleanupMonitor(); CrashGenerationCleaner(_pagedFile, 0, pages.Length, monitor).clean(_executor); // THEN AssertPagesVisited(monitor, pages.Length); AssertCleanedCrashPointers(monitor, 7); }
private void AssertSiblingPointerGeneration(long currentRightmostNode, long currentRightmostNodeGeneration, long currentRightmostRightSiblingPointer, long currentRightmostRightSiblingPointerGeneration, long newRightmostNode, long newRightmostNodeGeneration, long newRightmostLeftSiblingPointer, long newRightmostLeftSiblingPointerGeneration, GBPTreeConsistencyCheckVisitor visitor) { if (currentRightmostNodeGeneration > newRightmostLeftSiblingPointerGeneration && currentRightmostNode != NO_NODE_FLAG) { // Generation of left sibling is larger than that of the pointer from right sibling // Left siblings view: {_(9)}-(_)->{_} // Right siblings view: {_}<-(5)-{_(_)} visitor.pointerHasLowerGenerationThanNode(GBPTreePointerType.leftSibling(), newRightmostNode, newRightmostLeftSiblingPointerGeneration, newRightmostLeftSiblingPointer, currentRightmostNodeGeneration, _file); } if (currentRightmostRightSiblingPointerGeneration < newRightmostNodeGeneration && currentRightmostRightSiblingPointer != NO_NODE_FLAG) { // Generation of right sibling is larger than that of the pointer from left sibling // Left siblings view: {_(_)}-(5)->{_} // Right siblings view: {_}<-(_)-{_(9)} visitor.pointerHasLowerGenerationThanNode(GBPTreePointerType.rightSibling(), currentRightmostNode, currentRightmostRightSiblingPointerGeneration, currentRightmostRightSiblingPointer, newRightmostNodeGeneration, _file); } }
public static PageCorruption <KEY, VALUE> LeftSiblingPointToNonExisting <KEY, VALUE>() { return((cursor, layout, node, treeState) => overwriteGSPP(cursor, GBPTreePointerType.leftSibling().offset(node), treeState.stableGeneration(), GenerationSafePointer.MAX_POINTER)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void brokenPointer() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void BrokenPointer() { Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10); MutableObject <long> targetNode = new MutableObject <long>(); File[] indexFiles = SchemaIndexFiles(); CorruptIndexes(true, (tree, inspection) => { targetNode.Value = inspection.RootNode; tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(targetNode.Value, GBPTreeCorruption.broken(GBPTreePointerType.leftSibling()))); }, indexFiles); ConsistencyCheckService.Result result = RunConsistencyCheck(); assertFalse("Expected store to be considered inconsistent.", result.Successful); AssertResultContainsMessage(result, "Broken pointer found in tree node " + targetNode.Value); }
public override void PointerHasLowerGenerationThanNode(GBPTreePointerType pointerType, long sourceNode, long pointerGeneration, long pointer, long targetNodeGeneration, File file) { }
public override void CrashedPointer(long pageId, GBPTreePointerType pointerType, long generationA, long readPointerA, long pointerA, sbyte stateA, long generationB, long readPointerB, long pointerB, sbyte stateB, File file) { ThrowTreeStructureInconsistency("Crashed pointer found in tree node %d, pointer: %s%n slotA[%s]%n slotB[%s]", pageId, pointerType.ToString(), StateToString(generationA, readPointerA, pointerA, stateA), StateToString(generationB, readPointerB, pointerB, stateB)); }
public override void BrokenPointer(long pageId, GBPTreePointerType pointerType, long generationA, long readPointerA, long pointerA, sbyte stateA, long generationB, long readPointerB, long pointerB, sbyte stateB, File file) { _clean.setFalse(); @delegate.BrokenPointer(pageId, pointerType, generationA, readPointerA, pointerA, stateA, generationB, readPointerB, pointerB, stateB, file); }
public override void BrokenPointer(long pageId, GBPTreePointerType pointerType, long generationA, long readPointerA, long pointerA, sbyte stateA, long generationB, long readPointerB, long pointerB, sbyte stateB, File file) { }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void multipleCorruptionsInLabelScanStore() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MultipleCorruptionsInLabelScanStore() { Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10); MutableObject <long> rootNode = new MutableObject <long>(); File labelScanStoreFile = labelScanStoreFile(); CorruptIndexes(true, (tree, inspection) => { rootNode.Value = inspection.RootNode; tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(rootNode.Value, GBPTreeCorruption.broken(GBPTreePointerType.leftSibling()))); }, labelScanStoreFile); ConsistencyCheckService.Result result = RunConsistencyCheck(); assertFalse(result.Successful); AssertResultContainsMessage(result, "Index inconsistency: Broken pointer found in tree node " + rootNode.Value + ", pointerType='left sibling'"); AssertResultContainsMessage(result, "Number of inconsistent LABEL_SCAN_DOCUMENT records: 1"); }
public override void PointerHasLowerGenerationThanNode(GBPTreePointerType pointerType, long sourceNode, long pointerGeneration, long pointer, long targetNodeGeneration, File file) { _clean.setFalse(); @delegate.PointerHasLowerGenerationThanNode(pointerType, sourceNode, pointerGeneration, pointer, targetNodeGeneration, file); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void multipleCorruptions() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MultipleCorruptions() { Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10); MutableObject <long> internalNode = new MutableObject <long>(); File[] indexFiles = SchemaIndexFiles(); CorruptIndexes(true, (tree, inspection) => { long leafNode = inspection.LeafNodes.get(0); internalNode.Value = inspection.NodesPerLevel.get(1).get(1); int?internalNodeKeyCount = inspection.KeyCounts.get(internalNode.Value); tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(leafNode, GBPTreeCorruption.rightSiblingPointToNonExisting())); tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(internalNode.Value, GBPTreeCorruption.swapChildOrder(0, 1, internalNodeKeyCount))); tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(internalNode.Value, GBPTreeCorruption.broken(GBPTreePointerType.leftSibling()))); }, indexFiles); ConsistencyCheckService.Result result = RunConsistencyCheck(); AssertResultContainsMessage(result, "Index inconsistency: Sibling pointers misaligned."); AssertResultContainsMessage(result, "Index inconsistency: Expected range for this tree node is"); AssertResultContainsMessage(result, "Index inconsistency: Broken pointer found in tree node " + internalNode.Value + ", pointerType='left sibling'"); AssertResultContainsMessage(result, "Index inconsistency: Pointer (left sibling) in tree node " + internalNode.Value + " has pointer generation 0, but target node 0 has a higher generation 4."); }
public override void PointerHasLowerGenerationThanNode(GBPTreePointerType pointerType, long sourceNode, long pointerGeneration, long pointer, long targetNodeGeneration, File file) { ThrowTreeStructureInconsistency("Pointer (%s) in tree node %d has pointer generation %d, but target node %d has a higher generation %d.", pointerType.ToString(), sourceNode, pointerGeneration, pointer, targetNodeGeneration); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void pointerHasLowerGenerationThanNode() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void PointerHasLowerGenerationThanNode() { Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10); MutableObject <long> targetNode = new MutableObject <long>(); MutableObject <long> rightSibling = new MutableObject <long>(); File[] indexFiles = SchemaIndexFiles(); CorruptIndexes(true, (tree, inspection) => { ImmutableLongList leafNodes = inspection.LeafNodes; targetNode.Value = leafNodes.get(0); rightSibling.Value = leafNodes.get(1); tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(targetNode.Value, GBPTreeCorruption.rightSiblingPointerHasTooLowGeneration())); }, indexFiles); ConsistencyCheckService.Result result = RunConsistencyCheck(); assertFalse("Expected store to be considered inconsistent.", result.Successful); AssertResultContainsMessage(result, string.Format("Pointer ({0}) in tree node {1:D} has pointer generation {2:D}, but target node {3:D} has a higher generation {4:D}.", GBPTreePointerType.rightSibling(), targetNode.Value, 1, rightSibling.Value, 4)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void pointerToOldVersionOfTreeNode() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void PointerToOldVersionOfTreeNode() { Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10); MutableObject <long> targetNode = new MutableObject <long>(); File[] indexFiles = SchemaIndexFiles(); CorruptIndexes(true, (tree, inspection) => { targetNode.Value = inspection.RootNode; tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(targetNode.Value, GBPTreeCorruption.setPointer(GBPTreePointerType.successor(), 6))); }, indexFiles); ConsistencyCheckService.Result result = RunConsistencyCheck(); assertFalse("Expected store to be considered inconsistent.", result.Successful); AssertResultContainsMessage(result, "We ended up on tree node " + targetNode.Value + " which has a newer generation, successor is: 6"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void rightmostNodeHasRightSibling() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void RightmostNodeHasRightSibling() { Setup(GraphDatabaseSettings.SchemaIndex.NATIVE_BTREE10); File[] indexFiles = SchemaIndexFiles(); CorruptIndexes(true, (tree, inspection) => { long root = inspection.RootNode; tree.@unsafe(GBPTreeCorruption.pageSpecificCorruption(root, GBPTreeCorruption.setPointer(GBPTreePointerType.rightSibling(), 10))); }, indexFiles); ConsistencyCheckService.Result result = RunConsistencyCheck(); assertFalse("Expected store to be considered inconsistent.", result.Successful); AssertResultContainsMessage(result, "Expected rightmost node to have no right sibling but was 10"); }