use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.
the class RecoveryCorruptedTransactionLogIT method evenTruncateNewerTransactionLogFile.
@Test
void evenTruncateNewerTransactionLogFile() throws IOException {
DatabaseManagementService managementService = databaseFactory.build();
GraphDatabaseAPI database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
logFiles = buildDefaultLogFiles(getStoreId(database));
TransactionIdStore transactionIdStore = getTransactionIdStore(database);
long lastClosedTransactionBeforeStart = transactionIdStore.getLastClosedTransactionId();
for (int i = 0; i < 10; i++) {
generateTransaction(database);
}
long numberOfClosedTransactions = getTransactionIdStore(database).getLastClosedTransactionId() - lastClosedTransactionBeforeStart;
managementService.shutdown();
removeLastCheckpointRecordFromLastLogFile();
addRandomBytesToLastLogFile(this::randomNonZeroBytes);
startStopDbRecoveryOfCorruptedLogs();
assertEquals(numberOfClosedTransactions, recoveryMonitor.getNumberOfRecoveredTransactions());
}
use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.
the class KernelTransactionsTest method newKernelTransactions.
private KernelTransactions newKernelTransactions(Locks locks, StorageEngine storageEngine, TransactionCommitProcess commitProcess, boolean testKernelTransactions, Config config) {
LifeSupport life = new LifeSupport();
life.start();
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
when(transactionIdStore.getLastCommittedTransaction()).thenReturn(new TransactionId(0, 0, 0));
Tracers tracers = new Tracers("null", NullLog.getInstance(), new Monitors(), mock(JobScheduler.class), clock, config);
final DatabaseTracers databaseTracers = new DatabaseTracers(tracers);
KernelTransactions transactions;
if (testKernelTransactions) {
transactions = createTestTransactions(storageEngine, commitProcess, transactionIdStore, databaseTracers, locks, clock, databaseAvailabilityGuard);
} else {
transactions = createTransactions(storageEngine, commitProcess, transactionIdStore, databaseTracers, locks, clock, databaseAvailabilityGuard, config);
}
transactions.start();
return transactions;
}
use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.
the class InternalTransactionCommitProcessTest method shouldSuccessfullyCommitTransactionWithNoCommands.
@Test
void shouldSuccessfullyCommitTransactionWithNoCommands() throws Exception {
// GIVEN
long txId = 11;
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
TransactionAppender appender = new TestableTransactionAppender(transactionIdStore);
when(transactionIdStore.nextCommittingTransactionId()).thenReturn(txId);
StorageEngine storageEngine = mock(StorageEngine.class);
TransactionCommitProcess commitProcess = new InternalTransactionCommitProcess(appender, storageEngine);
PhysicalTransactionRepresentation noCommandTx = new PhysicalTransactionRepresentation(Collections.emptyList());
noCommandTx.setHeader(new byte[0], -1, -1, -1, -1, ANONYMOUS);
// WHEN
commitProcess.commit(new TransactionToApply(noCommandTx, NULL), commitEvent, INTERNAL);
verify(transactionIdStore).transactionCommitted(txId, FakeCommitment.CHECKSUM, FakeCommitment.TIMESTAMP, NULL);
}
use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.
the class EagerResultIT method setUp.
@BeforeEach
void setUp() {
storeDir = testDirectory.homePath();
testContextSupplier = new TestTransactionVersionContextSupplier();
database = startRestartableDatabase();
prepareData();
TransactionIdStore transactionIdStore = getTransactionIdStore();
testContextSupplier.setTestVersionContextSupplier(() -> {
var context = new TestVersionContext(transactionIdStore::getLastClosedTransactionId);
context.setWrongLastClosedTxId(false);
return context;
});
}
use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.
the class LogFilesBuilder method closePositionSupplier.
private Supplier<LogPosition> closePositionSupplier() throws IOException {
if (lastClosedPositionSupplier != null) {
return lastClosedPositionSupplier;
}
if (transactionIdStore != null) {
return () -> {
long[] lastClosedTransaction = transactionIdStore.getLastClosedTransaction();
return new LogPosition(lastClosedTransaction[1], lastClosedTransaction[2]);
};
}
if (fileBasedOperationsOnly) {
return () -> {
throw new UnsupportedOperationException("Current version of log files can't perform any " + "operation that require availability of transaction id store. Please build full version of log files " + "to be able to use them.");
};
}
if (readOnly) {
requireNonNull(pageCache, "Read only log files require page cache to be able to read committed " + "transaction info from store store.");
requireNonNull(databaseLayout, "Store directory is required.");
TransactionIdStore transactionIdStore = readOnlyTransactionIdStore();
return () -> {
long[] lastClosedTransaction = transactionIdStore.getLastClosedTransaction();
return new LogPosition(lastClosedTransaction[1], lastClosedTransaction[2]);
};
} else {
requireNonNull(dependencies, TransactionIdStore.class.getSimpleName() + " is required. " + "Please provide an instance or a dependencies where it can be found.");
return () -> {
long[] lastClosedTransaction = resolveDependency(TransactionIdStore.class).getLastClosedTransaction();
return new LogPosition(lastClosedTransaction[1], lastClosedTransaction[2]);
};
}
}
Aggregations