use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class TransactionLogCatchUpWriterTest method verifyCheckpointInLog.
private void verifyCheckpointInLog() throws IOException {
LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>(new RecordStorageCommandReaderFactory());
PhysicalLogFiles logFiles = new PhysicalLogFiles(storeDir, fs);
final LatestCheckPointFinder checkPointFinder = new LatestCheckPointFinder(logFiles, fs, logEntryReader);
LatestCheckPointFinder.LatestCheckPoint checkPoint = checkPointFinder.find(0);
assertNotNull(checkPoint.checkPoint);
assertTrue(checkPoint.commitsAfterCheckPoint);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportAnInconsistencyIfTxIdSequenceHasGaps.
@Test
public void shouldReportAnInconsistencyIfTxIdSequenceHasGaps() 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), 44L, newNodeCommandFunction.apply(4L));
writeTxContent(logFile(2), 45L, 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
System.out.println(handler.txIdSequenceInconsistencies);
assertEquals(1, handler.txIdSequenceInconsistencies.size());
assertEquals(42, handler.txIdSequenceInconsistencies.get(0).lastSeenTxId);
assertEquals(44, handler.txIdSequenceInconsistencies.get(0).currentTxId);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportNoInconsistenciesFromValidLog.
@Test
public void shouldReportNoInconsistenciesFromValidLog() throws Exception {
// Given
File log = logFile(1);
writeTxContent(log, 1, new Command.NodeCommand(new NodeRecord(42, false, false, -1, -1, 1), new NodeRecord(42, true, false, 42, -1, 1)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.NodeCommand(new NodeRecord(1, true, true, 2, -1, 1), new NodeRecord(1, true, false, -1, -1, 1)));
writeTxContent(log, 2, new Command.NodeCommand(new NodeRecord(2, false, false, -1, -1, 1), new NodeRecord(2, true, false, -1, -1, 1)), new Command.NodeCommand(new NodeRecord(42, true, false, 42, -1, 1), new NodeRecord(42, true, false, 24, 5, 1)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
boolean success = checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, NODE);
// Then
assertTrue(success);
assertEquals(0, handler.recordInconsistencies.size());
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportPropertyInconsistenciesFromDifferentLogs.
@Test
public void shouldReportPropertyInconsistenciesFromDifferentLogs() throws IOException {
// Given
File log1 = logFile(1);
File log2 = logFile(2);
File log3 = logFile(3);
writeTxContent(log1, 0, new Command.NodeCommand(new NodeRecord(42, false, false, -1, -1, 1), new NodeRecord(42, true, false, 42, -1, 1)), new Command.PropertyCommand(propertyRecord(5, true, -1, -1, 777), propertyRecord(5, true, -1, -1, 777)), new Command.NodeCommand(new NodeRecord(1, true, true, 2, -1, 1), new NodeRecord(1, true, false, -1, -1, 1)));
writeTxContent(log2, 0, new Command.PropertyCommand(propertyRecord(24, false, -1, -1), propertyRecord(24, true, -1, -1, 777)));
writeTxContent(log3, 0, new Command.PropertyCommand(propertyRecord(24, false, -1, -1), propertyRecord(24, true, -1, -1, 777)), new Command.NodeCommand(new NodeRecord(42, true, true, 42, -1, 1), new NodeRecord(42, true, true, 42, 10, 1)), new Command.PropertyCommand(propertyRecord(5, true, -1, -1, 777, 888), propertyRecord(5, true, -1, 9, 777, 888, 999)));
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(2, handler.recordInconsistencies.size());
RecordInconsistency inconsistency1 = handler.recordInconsistencies.get(0);
PropertyRecord seenRecord1 = (PropertyRecord) inconsistency1.committed.record();
PropertyRecord currentRecord1 = (PropertyRecord) inconsistency1.current.record();
assertEquals(24, seenRecord1.getId());
assertTrue(seenRecord1.inUse());
assertEquals(24, currentRecord1.getId());
assertFalse(currentRecord1.inUse());
assertEquals(2, inconsistency1.committed.logVersion());
assertEquals(3, inconsistency1.current.logVersion());
RecordInconsistency inconsistency2 = handler.recordInconsistencies.get(1);
PropertyRecord seenRecord2 = (PropertyRecord) inconsistency2.committed.record();
PropertyRecord currentRecord2 = (PropertyRecord) inconsistency2.current.record();
assertEquals(5, seenRecord2.getId());
assertEquals(777, seenRecord2.getPropertyBlock(0).getSingleValueInt());
assertEquals(5, currentRecord2.getId());
assertEquals(777, currentRecord2.getPropertyBlock(0).getSingleValueInt());
assertEquals(888, currentRecord2.getPropertyBlock(1).getSingleValueInt());
assertEquals(1, inconsistency2.committed.logVersion());
assertEquals(3, inconsistency2.current.logVersion());
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportNodeInconsistenciesFromSingleLog.
@Test
public void shouldReportNodeInconsistenciesFromSingleLog() throws IOException {
// Given
File log = logFile(1);
writeTxContent(log, 0, new Command.NodeCommand(new NodeRecord(42, false, false, -1, -1, 1), new NodeRecord(42, true, false, 42, -1, 1)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.NodeCommand(new NodeRecord(1, true, true, 2, -1, 1), new NodeRecord(1, true, false, -1, -1, 1)));
writeTxContent(log, 0, new Command.NodeCommand(new NodeRecord(2, false, false, -1, -1, 1), new NodeRecord(2, true, false, -1, -1, 1)), new Command.NodeCommand(new NodeRecord(42, true, false, 24, -1, 1), new NodeRecord(42, true, false, 24, 5, 1)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
boolean success = checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, NODE);
// Then
assertFalse(success);
assertEquals(1, handler.recordInconsistencies.size());
NodeRecord seenRecord = (NodeRecord) handler.recordInconsistencies.get(0).committed.record();
NodeRecord currentRecord = (NodeRecord) handler.recordInconsistencies.get(0).current.record();
assertEquals(42, seenRecord.getId());
assertEquals(42, seenRecord.getNextRel());
assertEquals(42, currentRecord.getId());
assertEquals(24, currentRecord.getNextRel());
}
Aggregations