use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PropertyStoreConsistentReadTest method assertRecordsEqual.
@Override
protected void assertRecordsEqual(PropertyRecord actualRecord, PropertyRecord expectedRecord) {
assertNotNull(actualRecord, "actualRecord");
assertNotNull(expectedRecord, "expectedRecord");
assertThat(actualRecord.getDeletedRecords()).as("getDeletedRecords").isEqualTo(expectedRecord.getDeletedRecords());
assertThat(actualRecord.getNextProp()).as("getNextProp").isEqualTo(expectedRecord.getNextProp());
assertThat(actualRecord.getNodeId()).as("getEntityId").isEqualTo(expectedRecord.getNodeId());
assertThat(actualRecord.getPrevProp()).as("getPrevProp").isEqualTo(expectedRecord.getPrevProp());
assertThat(actualRecord.getRelId()).as("getRelId").isEqualTo(expectedRecord.getRelId());
assertThat(actualRecord.getId()).as("getId").isEqualTo(expectedRecord.getId());
assertThat(actualRecord.getId()).as("getLongId").isEqualTo(expectedRecord.getId());
List<PropertyBlock> actualBlocks = Iterables.asList(actualRecord);
List<PropertyBlock> expectedBlocks = Iterables.asList(expectedRecord);
assertThat(actualBlocks.size()).as("getPropertyBlocks().size").isEqualTo(expectedBlocks.size());
for (int i = 0; i < actualBlocks.size(); i++) {
PropertyBlock actualBlock = actualBlocks.get(i);
PropertyBlock expectedBlock = expectedBlocks.get(i);
assertPropertyBlocksEqual(i, actualBlock, expectedBlock);
}
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class FullCheckIntegrationTest method serializeRule.
private void serializeRule(SchemaRule rule, SchemaRecord schemaRecord, TransactionDataBuilder tx, IdGenerator next) throws KernelException {
IntObjectMap<Value> protoProperties = SchemaStore.convertSchemaRuleToMap(rule, tx.tokenHolders());
Collection<PropertyBlock> blocks = new ArrayList<>();
DynamicRecordAllocator stringAllocator = null;
DynamicRecordAllocator arrayAllocator = null;
protoProperties.forEachKeyValue((keyId, value) -> {
PropertyBlock block = new PropertyBlock();
PropertyStore.encodeValue(block, keyId, value, stringAllocator, arrayAllocator, true, NULL, INSTANCE);
blocks.add(block);
});
long nextPropId = Record.NO_NEXT_PROPERTY.longValue();
PropertyRecord currRecord = newInitialisedPropertyRecord(next, rule);
for (PropertyBlock block : blocks) {
if (!currRecord.hasSpaceFor(block)) {
PropertyRecord nextRecord = newInitialisedPropertyRecord(next, rule);
linkAndWritePropertyRecord(currRecord, nextRecord.getId(), nextPropId, tx);
nextPropId = currRecord.getId();
currRecord = nextRecord;
}
currRecord.addPropertyBlock(block);
}
linkAndWritePropertyRecord(currRecord, Record.NO_PREVIOUS_PROPERTY.longValue(), nextPropId, tx);
nextPropId = currRecord.getId();
schemaRecord.initialize(true, nextPropId);
schemaRecord.setId(rule.getId());
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class DetectRandomSabotageIT method shouldDetectIndexConfigCorruption.
/* Failures/bugs found by the random sabotage are fixed and tested below, if they don't fit into any other FullCheck IT*/
// From Seed 1608234007554L
@Test
void shouldDetectIndexConfigCorruption() throws Exception {
// Given
SchemaStore schemaStore = neoStores.getSchemaStore();
long indexId = resolver.resolveDependency(IndexingService.class).getIndexIds().longIterator().next();
SchemaRecord schemaRecord = schemaStore.getRecord(indexId, schemaStore.newRecord(), RecordLoad.FORCE, NULL);
PropertyStore propertyStore = schemaStore.propertyStore();
PropertyRecord indexConfigPropertyRecord = propertyStore.getRecord(schemaRecord.getNextProp(), propertyStore.newRecord(), RecordLoad.FORCE, NULL);
propertyStore.ensureHeavy(indexConfigPropertyRecord, NULL);
// When
int[] tokenId = new int[1];
resolver.resolveDependency(TokenHolders.class).propertyKeyTokens().getOrCreateInternalIds(new String[] { "foo" }, tokenId);
PropertyBlock block = indexConfigPropertyRecord.iterator().next();
indexConfigPropertyRecord.removePropertyBlock(block.getKeyIndexId());
PropertyBlock newBlock = new PropertyBlock();
propertyStore.encodeValue(newBlock, tokenId[0], intValue(11), NULL, INSTANCE);
indexConfigPropertyRecord.addPropertyBlock(newBlock);
propertyStore.updateRecord(indexConfigPropertyRecord, NULL);
// then
ConsistencyCheckService.Result result = shutDownAndRunConsistencyChecker();
boolean hasSomeErrorOrWarning = result.summary().getTotalInconsistencyCount() > 0 || result.summary().getTotalWarningCount() > 0;
assertTrue(hasSomeErrorOrWarning);
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class SafePropertyChainReaderTest method testPropertyValueInconsistency.
private <T extends ConsistencyReport> void testPropertyValueInconsistency(Value consistentValue, Consumer<PropertyBlock> vandal, Class<T> expectedReportClass, Consumer<T> report) throws Exception {
// given
long nodeId;
try (AutoCloseable ignored = tx()) {
// (N)--->(P)---> (vandalized dynamic value chain)
long propId = propertyStore.nextId(CursorContext.NULL);
nodeId = node(nodeStore.nextId(CursorContext.NULL), propId, NULL);
PropertyBlock dynamicBlock = propertyValue(propertyKey1, consistentValue);
property(propId, NULL, NULL, dynamicBlock);
vandal.accept(dynamicBlock);
property(propId, NULL, NULL, dynamicBlock);
}
// when
checkNode(nodeId);
// then
expect(expectedReportClass, report);
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportPropertyInconsistencies.
@Test
void shouldReportPropertyInconsistencies() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
NodeRecord node = new NodeRecord(next.node());
PropertyRecord property = new PropertyRecord(next.property());
node.setNextProp(property.getId());
// Mess up the prev/next pointers a bit
property.setNextProp(1_000);
PropertyBlock block = new PropertyBlock();
block.setSingleBlock(next.propertyKey() | (((long) PropertyType.INT.intValue()) << 24) | (666L << 28));
property.addPropertyBlock(block);
tx.create(node);
tx.create(property);
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.PROPERTY, 2).verify(RecordType.NODE, 1).andThatsAllFolks();
}
Aggregations