use of org.neo4j.kernel.impl.transaction.tracing.LogFileCreateEvent in project neo4j by neo4j.
the class TransactionLogChannelAllocator method createLogChannel.
public PhysicalLogVersionedStoreChannel createLogChannel(long version, LongSupplier lastCommittedTransactionId) throws IOException {
AllocatedFile allocatedFile = allocateFile(version);
var storeChannel = allocatedFile.getStoreChannel();
var logFile = allocatedFile.getPath();
try (var scopedBuffer = new HeapScopedBuffer(CURRENT_FORMAT_LOG_HEADER_SIZE, logFilesContext.getMemoryTracker())) {
var buffer = scopedBuffer.getBuffer();
LogHeader header = readLogHeader(buffer, storeChannel, false, logFile);
if (header == null) {
try (LogFileCreateEvent ignored = databaseTracer.createLogFile()) {
// we always write file header from the beginning of the file
storeChannel.position(0);
long lastTxId = lastCommittedTransactionId.getAsLong();
LogHeader logHeader = new LogHeader(version, lastTxId, logFilesContext.getStoreId());
LogHeaderWriter.writeLogHeader(storeChannel, logHeader, logFilesContext.getMemoryTracker());
logHeaderCache.putHeader(version, logHeader);
}
}
byte formatVersion = header == null ? CURRENT_LOG_FORMAT_VERSION : header.getLogFormatVersion();
return new PhysicalLogVersionedStoreChannel(storeChannel, version, formatVersion, logFile, nativeChannelAccessor);
}
}
Aggregations