use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.
the class BatchingTransactionAppenderTest method shouldNotCallTransactionClosedOnFailedForceLogToDisk.
@Test
void shouldNotCallTransactionClosedOnFailedForceLogToDisk() throws Exception {
// GIVEN
long txId = 3;
String failureMessage = "Forces a failure";
FlushablePositionAwareChecksumChannel channel = spy(new InMemoryClosableChannel());
IOException failure = new IOException(failureMessage);
final Flushable flushable = mock(Flushable.class);
doAnswer(invocation -> {
invocation.callRealMethod();
return flushable;
}).when(channel).prepareForFlush();
when(logFile.forceAfterAppend(any())).thenThrow(failure);
when(logFile.getTransactionLogWriter()).thenReturn(new TransactionLogWriter(channel, new DbmsLogEntryWriterFactory(() -> LATEST)));
TransactionMetadataCache metadataCache = new TransactionMetadataCache();
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
when(transactionIdStore.nextCommittingTransactionId()).thenReturn(txId);
when(transactionIdStore.getLastCommittedTransaction()).thenReturn(new TransactionId(txId, BASE_TX_CHECKSUM, BASE_TX_COMMIT_TIMESTAMP));
TransactionAppender appender = life.add(new BatchingTransactionAppender(logFiles, NO_ROTATION, metadataCache, transactionIdStore, databaseHealth));
// WHEN
TransactionRepresentation transaction = mock(TransactionRepresentation.class);
when(transaction.additionalHeader()).thenReturn(new byte[0]);
var e = assertThrows(IOException.class, () -> appender.append(new TransactionToApply(transaction, NULL), logAppendEvent));
assertSame(failure, e);
verify(transactionIdStore).nextCommittingTransactionId();
verify(transactionIdStore, never()).transactionClosed(eq(txId), anyLong(), anyLong(), any(CursorContext.class));
}
use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.
the class PhysicalLogicalTransactionStoreTest method shouldOpenCleanStore.
@Test
void shouldOpenCleanStore() throws Exception {
// GIVEN
TransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
TransactionMetadataCache positionCache = new TransactionMetadataCache();
LifeSupport life = new LifeSupport();
final LogFiles logFiles = buildLogFiles(transactionIdStore);
life.add(logFiles);
life.add(new BatchingTransactionAppender(logFiles, NO_ROTATION, positionCache, transactionIdStore, DATABASE_HEALTH));
try {
// WHEN
life.start();
} finally {
life.shutdown();
}
}
use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.
the class LogFilesBuilder method lastCommittedIdSupplier.
private LongSupplier lastCommittedIdSupplier() throws IOException {
if (lastCommittedTransactionIdSupplier != null) {
return lastCommittedTransactionIdSupplier;
}
if (transactionIdStore != null) {
return transactionIdStore::getLastCommittedTransactionId;
}
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 transactionIdStore::getLastCommittedTransactionId;
} else {
requireNonNull(dependencies, TransactionIdStore.class.getSimpleName() + " is required. " + "Please provide an instance or a dependencies where it can be found.");
return () -> resolveDependency(TransactionIdStore.class).getLastCommittedTransactionId();
}
}
use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.
the class LogFilesBuilder method committingIdSupplier.
private LongSupplier committingIdSupplier() throws IOException {
if (transactionIdStore != null) {
return transactionIdStore::committingTransactionId;
}
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 transactionIdStore::committingTransactionId;
} else {
requireNonNull(dependencies, TransactionIdStore.class.getSimpleName() + " is required. " + "Please provide an instance or a dependencies where it can be found.");
return () -> resolveDependency(TransactionIdStore.class).committingTransactionId();
}
}
use of org.neo4j.storageengine.api.TransactionIdStore in project neo4j by neo4j.
the class GraphStoreFixture method startDatabaseAndExtractComponents.
private void startDatabaseAndExtractComponents() {
managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setFileSystem(testDirectory.getFileSystem()).setConfig(GraphDatabaseSettings.record_format, formatName).setConfig(GraphDatabaseInternalSettings.label_block_size, 60).setConfig(GraphDatabaseInternalSettings.consistency_check_on_apply, false).setConfig(getConfig()).build();
database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
DependencyResolver dependencyResolver = database.getDependencyResolver();
commitProcess = new InternalTransactionCommitProcess(dependencyResolver.resolveDependency(TransactionAppender.class), dependencyResolver.resolveDependency(StorageEngine.class));
transactionIdStore = database.getDependencyResolver().resolveDependency(TransactionIdStore.class);
storageEngine = dependencyResolver.resolveDependency(RecordStorageEngine.class);
neoStores = storageEngine.testAccessNeoStores();
indexingService = dependencyResolver.resolveDependency(IndexingService.class);
directStoreAccess = new DirectStoreAccess(neoStores, dependencyResolver.resolveDependency(IndexProviderMap.class), dependencyResolver.resolveDependency(TokenHolders.class), dependencyResolver.resolveDependency(IndexStatisticsStore.class), dependencyResolver.resolveDependency(IdGeneratorFactory.class));
countsStore = storageEngine.countsAccessor();
groupDegreesStore = storageEngine.relationshipGroupDegreesStore();
pageCache = dependencyResolver.resolveDependency(PageCache.class);
}
Aggregations