private static Function<TransactionId,Boolean> txInfoAcceptanceOnIdAndTimestamp( long id, long timestamp ) { return txInfo -> txInfo.transactionId() == id && txInfo.commitTimestamp() == timestamp; } }
void writeLastTxInformation( DatabaseLayout migrationStructure, TransactionId txInfo ) throws IOException { writeTxLogCounters( fileSystem, lastTxInformationFile( migrationStructure ), txInfo.transactionId(), txInfo.checksum(), txInfo.commitTimestamp() ); }
@Test public void lastTxCommitTimestampShouldBeBaseInNewStore() { try ( MetaDataStore metaDataStore = newMetaDataStore() ) { long timestamp = metaDataStore.getLastCommittedTransaction().commitTimestamp(); assertThat( timestamp, equalTo( TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP ) ); } }
KernelTransactionImplementation tx = localTxPool.acquire(); StatementLocks statementLocks = statementLocksFactory.newInstance(); tx.initialize( lastCommittedTransaction.transactionId(), lastCommittedTransaction.commitTimestamp(), statementLocks, type, securityContext, timeout, userTransactionIdCounter.incrementAndGet() ); return tx;
lastTxInfo.checksum() ); MetaDataStore.setRecord( pageCache, migrationDirNeoStore, Position.LAST_TRANSACTION_COMMIT_TIMESTAMP, lastTxInfo.commitTimestamp() ); MetaDataStore.setRecord( pageCache, migrationDirNeoStore, Position.UPGRADE_TRANSACTION_COMMIT_TIMESTAMP, lastTxInfo.commitTimestamp() );
@Test public void shouldGenerateTransactionInformationWhenLogsAreEmpty() throws Exception { // given long txId = 1; DatabaseLayout databaseLayout = directory.databaseLayout(); File neoStore = databaseLayout.metadataStore(); neoStore.createNewFile(); Config config = mock( Config.class ); LogService logService = new SimpleLogService( NullLogProvider.getInstance(), NullLogProvider.getInstance() ); // when // ... transaction info not in neo store assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_ID ) ); assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_CHECKSUM ) ); assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP ) ); // ... and with migrator StoreMigrator migrator = new StoreMigrator( fileSystemRule.get(), pageCache, config, logService, jobScheduler ); TransactionId actual = migrator.extractTransactionIdInformation( neoStore, txId ); // then assertEquals( txId, actual.transactionId() ); assertEquals( TransactionIdStore.BASE_TX_CHECKSUM, actual.checksum() ); assertEquals( TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP, actual.commitTimestamp() ); }
@Test public void shouldGenerateTransactionInformationWhenLogsNotPresent() throws Exception { // given long txId = 42; DatabaseLayout databaseLayout = directory.databaseLayout(); File neoStore = databaseLayout.metadataStore(); neoStore.createNewFile(); Config config = mock( Config.class ); LogService logService = new SimpleLogService( NullLogProvider.getInstance(), NullLogProvider.getInstance() ); // when // ... transaction info not in neo store assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_ID ) ); assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_CHECKSUM ) ); assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP ) ); // ... and with migrator StoreMigrator migrator = new StoreMigrator( fileSystemRule.get(), pageCache, config, logService, jobScheduler ); TransactionId actual = migrator.extractTransactionIdInformation( neoStore, txId ); // then assertEquals( txId, actual.transactionId() ); assertEquals( TransactionIdStore.UNKNOWN_TX_CHECKSUM, actual.checksum() ); assertEquals( TransactionIdStore.UNKNOWN_TX_COMMIT_TIMESTAMP, actual.commitTimestamp() ); }
assertEquals( LogEntryStart.checksum( additionalHeaderData, masterId, authorId ), transactionIdStore.getLastCommittedTransaction().checksum() ); assertEquals( commitTimestamp, transactionIdStore.getLastCommittedTransaction().commitTimestamp() ); assertEquals( logVersion, lastClosedTransaction[1] ); assertEquals( marker.getByteOffset(), lastClosedTransaction[2] );
void writeLastTxInformation( DatabaseLayout migrationStructure, TransactionId txInfo ) throws IOException { writeTxLogCounters( fileSystem, lastTxInformationFile( migrationStructure ), txInfo.transactionId(), txInfo.checksum(), txInfo.commitTimestamp() ); }
KernelTransactionImplementation tx = localTxPool.acquire(); StatementLocks statementLocks = statementLocksFactory.newInstance(); tx.initialize( lastCommittedTransaction.transactionId(), lastCommittedTransaction.commitTimestamp(), statementLocks, type, securityContext, timeout, userTransactionIdCounter.incrementAndGet() ); return tx;
lastTxInfo.checksum() ); MetaDataStore.setRecord( pageCache, migrationDirNeoStore, Position.LAST_TRANSACTION_COMMIT_TIMESTAMP, lastTxInfo.commitTimestamp() ); MetaDataStore.setRecord( pageCache, migrationDirNeoStore, Position.UPGRADE_TRANSACTION_COMMIT_TIMESTAMP, lastTxInfo.commitTimestamp() );