use of org.neo4j.consistency.checking.full.ConsistencyFlags in project neo4j by neo4j.
the class ConsistencyCheckWithCorruptGBPTreeIT method corruptionInCountsStore.
@Test
void corruptionInCountsStore() throws Exception {
MutableObject<Long> rootNode = new MutableObject<>();
Path countsStoreFile = countsStoreFile();
final LayoutBootstrapper countsLayoutBootstrapper = (indexFile, pageCache, meta) -> new CountsLayout();
corruptIndexes(fs, readOnly(), (tree, inspection) -> {
rootNode.setValue(inspection.getRootNode());
tree.unsafe(pageSpecificCorruption(rootNode.getValue(), GBPTreeCorruption.broken(GBPTreePointerType.leftSibling())), CursorContext.NULL);
}, countsLayoutBootstrapper, countsStoreFile);
ConsistencyFlags flags = new ConsistencyFlags(false, false, true);
ConsistencyCheckService.Result result = runConsistencyCheck(NullLogProvider.getInstance(), flags);
assertFalse(result.isSuccessful());
assertResultContainsMessage(result, "Index inconsistency: Broken pointer found in tree node " + rootNode.getValue() + ", pointerType='left sibling'");
assertResultContainsMessage(result, "Number of inconsistent COUNTS records: 1");
}
use of org.neo4j.consistency.checking.full.ConsistencyFlags in project neo4j by neo4j.
the class RelationshipCheckerWithRelationshipTypeIndexTest method doVerifyCorrectReport.
@SafeVarargs
private void doVerifyCorrectReport(Density density, ThrowingConsumer<IndexUpdater, IndexEntryConflictException> targetRelationshipAction, Consumer<ConsistencyReport.RelationshipTypeScanConsistencyReport>... expectedCalls) throws Exception {
double recordFrequency = densityAsFrequency(density);
int nbrOfRelationships = random.nextInt(1, 2 * IDS_PER_CHUNK);
int targetRelationshipRelationship = random.nextInt(nbrOfRelationships);
// given
try (Transaction tx = db.beginTx();
IndexUpdater writer = relationshipTypeIndexWriter()) {
for (int i = 0; i < nbrOfRelationships; i++) {
if (i == targetRelationshipRelationship) {
targetRelationshipAction.accept(writer);
} else {
if (random.nextDouble() < recordFrequency) {
createCompleteEntry(writer, type);
} else {
notInUse(createStoreEntry(type));
}
}
}
tx.commit();
}
// when
ConsistencyFlags flags = new ConsistencyFlags(true, true, true);
check(context(flags));
// then
if (expectedCalls != null) {
for (Consumer<ConsistencyReport.RelationshipTypeScanConsistencyReport> expectedCall : expectedCalls) {
expect(ConsistencyReport.RelationshipTypeScanConsistencyReport.class, expectedCall);
}
} else {
verifyNoInteractions(monitor);
}
}
use of org.neo4j.consistency.checking.full.ConsistencyFlags in project neo4j by neo4j.
the class LabelScanStoreTxApplyRaceIT method shouldStressIt.
/**
* The test case is basically loads of concurrent CREATE/DELETE NODE or sometimes just CREATE, keeping the created node in an array
* for dedicated deleter threads to pick up and delete as fast as they can see them. This concurrently with large creation transactions.
*/
@Test
void shouldStressIt() throws Throwable {
// given
Race race = new Race().withMaxDuration(5, TimeUnit.SECONDS);
AtomicReferenceArray<Node> nodeHeads = new AtomicReferenceArray<>(NUMBER_OF_CREATORS);
for (int i = 0; i < NUMBER_OF_CREATORS; i++) {
race.addContestant(creator(nodeHeads, i));
}
race.addContestants(NUMBER_OF_DELETORS, deleter(nodeHeads));
// when
race.go();
// then
DatabaseLayout dbLayout = db.databaseLayout();
managementService.shutdown();
assertTrue(new ConsistencyCheckService().runFullConsistencyCheck(dbLayout, defaults(GraphDatabaseSettings.neo4j_home, testDirectory.homePath()), NONE, new Log4jLogProvider(System.out), false, new ConsistencyFlags(true, true, true)).isSuccessful());
}
use of org.neo4j.consistency.checking.full.ConsistencyFlags in project neo4j by neo4j.
the class CheckConsistencyCommandIT method passesOnCheckParameters.
@Test
void passesOnCheckParameters() throws Exception {
ConsistencyCheckService consistencyCheckService = mock(ConsistencyCheckService.class);
CheckConsistencyCommand checkConsistencyCommand = new CheckConsistencyCommand(new ExecutionContext(homeDir, confPath), consistencyCheckService);
when(consistencyCheckService.runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), any(ConsistencyFlags.class))).thenReturn(ConsistencyCheckService.Result.success(null, null));
CommandLine.populateCommand(checkConsistencyCommand, "--database=mydb", "--check-graph=false", "--check-indexes=false", "--check-index-structure=true");
checkConsistencyCommand.execute();
verify(consistencyCheckService).runFullConsistencyCheck(any(), any(), any(), any(), any(), anyBoolean(), any(), eq(new ConsistencyFlags(false, false, true)));
}
use of org.neo4j.consistency.checking.full.ConsistencyFlags in project neo4j by neo4j.
the class ConsistencyCheckWithCorruptGBPTreeIT method shouldNotCheckIndexesIfConfiguredNotTo.
@Test
void shouldNotCheckIndexesIfConfiguredNotTo() throws Exception {
MutableObject<Long> targetNode = new MutableObject<>();
Path[] indexFiles = schemaIndexFiles();
corruptIndexes(readOnly(), (tree, inspection) -> {
targetNode.setValue(inspection.getRootNode());
tree.unsafe(pageSpecificCorruption(targetNode.getValue(), GBPTreeCorruption.notATreeNode()), CursorContext.NULL);
}, indexFiles);
ConsistencyFlags flags = new ConsistencyFlags(true, false, false);
ConsistencyCheckService.Result result = runConsistencyCheck(NullLogProvider.getInstance(), flags);
assertTrue(result.isSuccessful(), "Expected store to be consistent when not checking indexes.");
}
Aggregations