use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldDetectAnInconsistentCheckPointPointingToAByteOffsetNotInTheFile.
@Test
public void shouldDetectAnInconsistentCheckPointPointingToAByteOffsetNotInTheFile() throws Exception {
// given
ensureLogExists(logFile(1));
writeCheckPoint(logFile(2), 1, 42);
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(2, handler.checkPointInconsistencies.get(0).logVersion);
assertEquals(new LogPosition(1, 42), handler.checkPointInconsistencies.get(0).logPosition);
assertEquals(LOG_HEADER_SIZE, handler.checkPointInconsistencies.get(0).size);
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportNeoStoreInconsistenciesFromSingleLog.
@Test
public void shouldReportNeoStoreInconsistenciesFromSingleLog() throws IOException {
// Given
File log = logFile(1);
writeTxContent(log, 0, new Command.NeoStoreCommand(new NeoStoreRecord(), createNeoStoreRecord(42)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.NeoStoreCommand(createNeoStoreRecord(42), createNeoStoreRecord(21)));
writeTxContent(log, 0, new Command.NeoStoreCommand(createNeoStoreRecord(42), createNeoStoreRecord(33)));
CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
// When
checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, NEO_STORE);
// Then
assertEquals(1, handler.recordInconsistencies.size());
NeoStoreRecord seenRecord = (NeoStoreRecord) handler.recordInconsistencies.get(0).committed.record();
NeoStoreRecord currentRecord = (NeoStoreRecord) handler.recordInconsistencies.get(0).current.record();
assertEquals(21, seenRecord.getNextProp());
assertEquals(42, currentRecord.getNextProp());
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldNotReportInconsistencyIfTheCheckPointAreValidOrTheyReferToPrunedLogs.
@Test
public void shouldNotReportInconsistencyIfTheCheckPointAreValidOrTheyReferToPrunedLogs() throws Exception {
// given
writeCheckPoint(logFile(1), 0, LOG_HEADER_SIZE);
writeCheckPoint(logFile(2), 1, LOG_HEADER_SIZE);
writeCheckPoint(logFile(3), 3, 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
assertTrue(handler.checkPointInconsistencies.isEmpty());
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class CheckTxLogsTest method shouldReportTransactionIdAndInconsistencyCount.
@Test
public void shouldReportTransactionIdAndInconsistencyCount() 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)), new Command.NodeCommand(new NodeRecord(5, true, true, 2, -1, 1), new NodeRecord(5, true, false, -1, -1, 1)));
writeTxContent(log, 1, new Command.NodeCommand(new NodeRecord(2, false, false, -1, -1, 1), new NodeRecord(2, true, false, -1, -1, 1)), new Command.NodeCommand(// inconsistent
new NodeRecord(5, true, true, 2, -1, 1), new NodeRecord(5, true, false, -1, -1, 1)), new Command.NodeCommand(new NodeRecord(1, true, false, -1, -1, 1), new NodeRecord(1, true, true, 2, 1, 1)), new Command.NodeCommand(// inconsistent
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
checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, NODE);
// Then
assertEquals(2, handler.recordInconsistencies.size());
assertEquals(0, handler.recordInconsistencies.get(0).committed.txId());
assertEquals(1, handler.recordInconsistencies.get(0).current.txId());
assertEquals(0, handler.recordInconsistencies.get(1).committed.txId());
assertEquals(1, handler.recordInconsistencies.get(1).current.txId());
}
use of org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles in project neo4j by neo4j.
the class BackupServiceIT method checkPreviousCommittedTxIdFromLog.
private void checkPreviousCommittedTxIdFromLog(long logVersion, long txId) throws IOException {
// Assert header of specified log version containing correct txId
PhysicalLogFiles logFiles = new PhysicalLogFiles(backupDir, fileSystem);
LogHeader logHeader = LogHeaderReader.readLogHeader(fileSystem, logFiles.getLogFileForVersion(logVersion));
assertEquals(txId, logHeader.lastCommittedTxId);
}
Aggregations