use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportPropertyInconsistenciesFromSingleLog.
@Test
public void shouldReportPropertyInconsistenciesFromSingleLog() throws IOException {
// Given
File log = logFile(1);
writeTxContent(log, 0, new Command.PropertyCommand(propertyRecord(42, false, -1, -1), propertyRecord(42, true, -1, -1, 10)), new Command.PropertyCommand(propertyRecord(42, true, -1, -1, 10), propertyRecord(42, true, 24, -1, 10)));
writeTxContent(log, 0, new Command.NodeCommand(new NodeRecord(2, false, false, -1, -1, 1), new NodeRecord(2, true, false, -1, -1, 1)), new Command.PropertyCommand(propertyRecord(42, true, -1, -1, 10), propertyRecord(42, true, -1, -1, 10, 20)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
boolean success = checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, PROPERTY);
// Then
assertFalse(success);
assertEquals(1, handler.recordInconsistencies.size());
PropertyRecord seenRecord = (PropertyRecord) handler.recordInconsistencies.get(0).committed.record();
PropertyRecord currentRecord = (PropertyRecord) handler.recordInconsistencies.get(0).current.record();
assertEquals(42, seenRecord.getId());
assertEquals(24, seenRecord.getPrevProp());
assertEquals(42, currentRecord.getId());
assertEquals(-1, currentRecord.getPrevProp());
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldDetectAnInconsistentCheckPointPointingToALogFileGreaterThanMaxLogVersion.
@Test
public void shouldDetectAnInconsistentCheckPointPointingToALogFileGreaterThanMaxLogVersion() throws Exception {
// given
File log = logFile(1);
writeCheckPoint(log, 2, LOG_HEADER_SIZE);
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// when
checker.validateCheckPoints(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler);
// then
assertEquals(1, handler.checkPointInconsistencies.size());
assertEquals(1, handler.checkPointInconsistencies.get(0).logVersion);
assertEquals(new LogPosition(2, LOG_HEADER_SIZE), handler.checkPointInconsistencies.get(0).logPosition);
assertThat(handler.checkPointInconsistencies.get(0).size, lessThan(0L));
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportRelationshipGroupInconsistenciesFromDifferentLogs.
@Test
public void shouldReportRelationshipGroupInconsistenciesFromDifferentLogs() throws IOException {
// Given
File log1 = logFile(1);
File log2 = logFile(2);
File log3 = logFile(3);
writeTxContent(log1, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, -1, -1, -1, -1, -1, -1, false), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(21, 1, 2, 3, 4, 5, 6, true), new RelationshipGroupRecord(21, -1, -1, -1, -1, -1, -1, false)));
writeTxContent(log2, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, 1, 2, 3, 9, 5, 6, true), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)));
writeTxContent(log3, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(53, 1, 2, 3, 4, 5, 6, true), new RelationshipGroupRecord(53, 1, 2, 30, 4, 14, 6, true)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, false), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, false)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, RELATIONSHIP_GROUP);
// Then
assertEquals(2, handler.recordInconsistencies.size());
RelationshipGroupRecord seenRecord1 = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).committed.record();
RelationshipGroupRecord currentRecord1 = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).current.record();
assertEquals(42, seenRecord1.getId());
assertEquals(4, seenRecord1.getFirstLoop());
assertEquals(42, currentRecord1.getId());
assertEquals(9, currentRecord1.getFirstLoop());
RelationshipGroupRecord seenRecord2 = (RelationshipGroupRecord) handler.recordInconsistencies.get(1).committed.record();
RelationshipGroupRecord currentRecord2 = (RelationshipGroupRecord) handler.recordInconsistencies.get(1).current.record();
assertEquals(42, seenRecord2.getId());
assertTrue(seenRecord2.inUse());
assertEquals(42, currentRecord2.getId());
assertFalse(currentRecord2.inUse());
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportAnInconsistencyIfTxIdSequenceIsNotStrictlyIncreasing.
@Test
public void shouldReportAnInconsistencyIfTxIdSequenceIsNotStrictlyIncreasing() throws Exception {
// given
Function<Long, Command.NodeCommand> newNodeCommandFunction = (i) -> new Command.NodeCommand(new NodeRecord(i, false, false, -1, -1, -1), new NodeRecord(i, true, false, -1, -1, -1));
writeTxContent(logFile(1), 40L, newNodeCommandFunction.apply(1L));
writeTxContent(logFile(1), 41L, newNodeCommandFunction.apply(2L));
writeTxContent(logFile(1), 42L, newNodeCommandFunction.apply(3L));
writeTxContent(logFile(2), 42L, newNodeCommandFunction.apply(4L));
writeTxContent(logFile(2), 43L, newNodeCommandFunction.apply(5L));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// when
checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, CHECK_TYPES);
// then
assertEquals(1, handler.txIdSequenceInconsistencies.size());
assertEquals(42, handler.txIdSequenceInconsistencies.get(0).lastSeenTxId);
assertEquals(42, handler.txIdSequenceInconsistencies.get(0).currentTxId);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportRelationshipGroupInconsistenciesFromSingleLog.
@Test
public void shouldReportRelationshipGroupInconsistenciesFromSingleLog() throws IOException {
// Given
File log = logFile(1);
writeTxContent(log, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, -1, -1, -1, -1, -1, -1, false), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(21, 1, 2, 3, 4, 5, 7, true), new RelationshipGroupRecord(21, -1, -1, -1, -1, -1, -1, false)));
writeTxContent(log, 0, new Command.RelationshipGroupCommand(new RelationshipGroupRecord(53, 1, 2, 3, 4, 5, 6, true), new RelationshipGroupRecord(53, 1, 2, 30, 4, 14, 6, true)), new Command.RelationshipGroupCommand(new RelationshipGroupRecord(42, 1, 2, 3, 9, 5, 6, true), new RelationshipGroupRecord(42, 1, 2, 3, 4, 5, 6, true)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, RELATIONSHIP_GROUP);
// Then
assertEquals(1, handler.recordInconsistencies.size());
RelationshipGroupRecord seenRecord = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).committed.record();
RelationshipGroupRecord currentRecord = (RelationshipGroupRecord) handler.recordInconsistencies.get(0).current.record();
assertEquals(42, seenRecord.getId());
assertEquals(4, seenRecord.getFirstLoop());
assertEquals(42, currentRecord.getId());
assertEquals(9, currentRecord.getFirstLoop());
}
Aggregations