use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class ReadOnlyLogVersionRepositoryIT method tracePageCacheAccessOnReadOnlyLogRepoConstruction.
@Test
void tracePageCacheAccessOnReadOnlyLogRepoConstruction() throws IOException {
var pageCacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnReadOnlyLogRepoConstruction"));
new ReadOnlyLogVersionRepository(pageCache, databaseLayout, cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isEqualTo(2);
assertThat(cursorTracer.unpins()).isEqualTo(2);
assertThat(cursorTracer.hits()).isEqualTo(2);
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class CommitProcessTracingIT method tracePageCacheAccessOnEmptyTransactionApply.
@Test
void tracePageCacheAccessOnEmptyTransactionApply() throws TransactionFailureException {
var transaction = new PhysicalTransactionRepresentation(emptyList(), EMPTY_BYTE_ARRAY, 0, 0, 0, 0, ANONYMOUS);
var pageCacheTracer = new DefaultPageCacheTracer();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnEmptyTransactionApply"))) {
assertZeroCursor(cursorContext);
commitProcess.commit(new TransactionToApply(transaction, cursorContext), NULL, EXTERNAL);
assertCursor(cursorContext, 2);
}
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class CommitProcessTracingIT method tracePageCacheAccessOnCommandCreation.
@Test
void tracePageCacheAccessOnCommandCreation() throws KernelException {
long sourceId;
try (Transaction transaction = database.beginTx()) {
sourceId = transaction.createNode(Label.label("a")).getId();
transaction.commit();
}
var pageCacheTracer = new DefaultPageCacheTracer();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnCommandCreation"));
var reader = storageEngine.newReader()) {
assertZeroCursor(cursorContext);
try (CommandCreationContext context = storageEngine.newCommandCreationContext(INSTANCE)) {
context.initialize(cursorContext);
List<StorageCommand> commands = new ArrayList<>();
var txState = new TxState();
txState.nodeDoAddLabel(1, sourceId);
storageEngine.createCommands(commands, txState, reader, context, IGNORE, LockTracer.NONE, 0, NO_DECORATION, cursorContext, INSTANCE);
}
assertCursor(cursorContext, 2);
}
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class IndexingService method init.
/**
* Called while the database starts up, before recovery.
*/
@Override
public void init() throws IOException {
validateDefaultProviderExisting();
try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(INIT_TAG))) {
indexMapRef.modify(indexMap -> {
Map<InternalIndexState, List<IndexLogRecord>> indexStates = new EnumMap<>(InternalIndexState.class);
for (IndexDescriptor descriptor : indexDescriptors) {
// No index (except NLI) is allowed to have the name generated for NLI.
if (descriptor.getName().equals(IndexDescriptor.NLI_GENERATED_NAME) && !(descriptor.schema().isAnyTokenSchemaDescriptor() && descriptor.schema().entityType() == NODE)) {
throw new IllegalStateException("Index '" + descriptor.userDescription(tokenNameLookup) + "' is using a reserved name: '" + IndexDescriptor.NLI_GENERATED_NAME + "'. This index must be removed on an earlier version " + "to be able to use binaries for version 4.3 or newer.");
}
IndexProxy indexProxy;
IndexProviderDescriptor providerDescriptor = descriptor.getIndexProvider();
IndexProvider provider = providerMap.lookup(providerDescriptor);
InternalIndexState initialState = provider.getInitialState(descriptor, cursorContext);
indexStates.computeIfAbsent(initialState, internalIndexState -> new ArrayList<>()).add(new IndexLogRecord(descriptor));
internalLog.debug(indexStateInfo("init", initialState, descriptor));
switch(initialState) {
case ONLINE:
monitor.initialState(databaseName, descriptor, ONLINE);
indexProxy = indexProxyCreator.createOnlineIndexProxy(descriptor);
break;
case POPULATING:
// The database was shut down during population, or a crash has occurred, or some other sad thing.
monitor.initialState(databaseName, descriptor, POPULATING);
indexProxy = indexProxyCreator.createRecoveringIndexProxy(descriptor);
break;
case FAILED:
monitor.initialState(databaseName, descriptor, FAILED);
IndexPopulationFailure failure = failure(provider.getPopulationFailure(descriptor, cursorContext));
indexProxy = indexProxyCreator.createFailedIndexProxy(descriptor, failure);
break;
default:
throw new IllegalArgumentException("" + initialState);
}
indexMap.putIndexProxy(indexProxy);
}
logIndexStateSummary("init", indexStates);
return indexMap;
});
}
indexStatisticsStore.init();
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class GBPTreeGenericCountsStoreTest method shouldRebuildOnMismatchingLastCommittedTxId.
@Test
void shouldRebuildOnMismatchingLastCommittedTxId() throws IOException {
// given some pre-state
long countsStoreTxId = BASE_TX_ID + 1;
try (CountUpdater updater = countsStore.updater(countsStoreTxId, NULL)) {
updater.increment(nodeKey(1), 1);
}
// when
countsStore.checkpoint(NULL);
closeCountsStore();
MutableBoolean rebuildTriggered = new MutableBoolean();
openCountsStore(new Rebuilder() {
@Override
public long lastCommittedTxId() {
return countsStoreTxId + 1;
}
@Override
public void rebuild(CountUpdater updater, CursorContext cursorContext, MemoryTracker memoryTracker) {
rebuildTriggered.setTrue();
}
});
// then
assertThat(rebuildTriggered.booleanValue()).isTrue();
}
Aggregations