Esempio n. 1
0
        public virtual KernelTransaction NewInstance(KernelTransaction.Type type, LoginContext loginContext, long timeout)
        {
            AssertCurrentThreadIsNotBlockingNewTransactions();
            SecurityContext securityContext = loginContext.Authorize(_tokenHolders.propertyKeyTokens().getOrCreateId, _currentDatabaseName);

            try
            {
                while (!_newTransactionsLock.readLock().tryLock(1, TimeUnit.SECONDS))
                {
                    AssertRunning();
                }
                try
                {
                    AssertRunning();
                    TransactionId lastCommittedTransaction = _transactionIdStore.LastCommittedTransaction;
                    KernelTransactionImplementation tx     = _localTxPool.acquire();
                    StatementLocks statementLocks          = _statementLocksFactory.newInstance();
                    tx.Initialize(lastCommittedTransaction.TransactionIdConflict(), lastCommittedTransaction.CommitTimestamp(), statementLocks, type, securityContext, timeout, _userTransactionIdCounter.incrementAndGet());
                    return(tx);
                }
                finally
                {
                    _newTransactionsLock.readLock().unlock();
                }
            }
            catch (InterruptedException ie)
            {
                Thread.interrupted();
                throw new TransactionFailureException("Fail to start new transaction.", ie);
            }
        }
Esempio n. 2
0
        private static long LastCommittedTxTimestamp(HighlyAvailableGraphDatabase db)
        {
            DependencyResolver resolver      = Db.DependencyResolver;
            MetaDataStore      metaDataStore = resolver.ResolveDependency(typeof(MetaDataStore));
            TransactionId      txInfo        = metaDataStore.LastCommittedTransaction;

            return(txInfo.CommitTimestamp());
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void updateOrAddNeoStoreFieldsAsPartOfMigration(org.neo4j.io.layout.DatabaseLayout migrationStructure, org.neo4j.io.layout.DatabaseLayout sourceDirectoryStructure, String versionToMigrateTo, org.neo4j.kernel.impl.transaction.log.LogPosition lastClosedTxLogPosition) throws java.io.IOException
        private void UpdateOrAddNeoStoreFieldsAsPartOfMigration(DatabaseLayout migrationStructure, DatabaseLayout sourceDirectoryStructure, string versionToMigrateTo, LogPosition lastClosedTxLogPosition)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File storeDirNeoStore = sourceDirectoryStructure.metadataStore();
            File storeDirNeoStore = sourceDirectoryStructure.MetadataStore();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.io.File migrationDirNeoStore = migrationStructure.metadataStore();
            File migrationDirNeoStore = migrationStructure.MetadataStore();

            fileOperation(COPY, _fileSystem, sourceDirectoryStructure, migrationStructure, Iterables.iterable(DatabaseFile.METADATA_STORE), true, ExistingTargetStrategy.SKIP);

            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.UPGRADE_TRANSACTION_ID, MetaDataStore.getRecord(_pageCache, storeDirNeoStore, MetaDataStore.Position.LAST_TRANSACTION_ID));
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.UPGRADE_TIME, DateTimeHelper.CurrentUnixTimeMillis());

            // Store the checksum of the transaction id the upgrade is at right now. Store it both as
            // LAST_TRANSACTION_CHECKSUM and UPGRADE_TRANSACTION_CHECKSUM. Initially the last transaction and the
            // upgrade transaction will be the same, but imagine this scenario:
            //  - legacy store is migrated on instance A at transaction T
            //  - upgraded store is copied, via backup or HA or whatever to instance B
            //  - instance A performs a transaction
            //  - instance B would like to communicate with A where B's last transaction checksum
            //    is verified on A. A, at this point not having logs from pre-migration era, will need to
            //    know the checksum of transaction T to accommodate for this request from B. A will be able
            //    to look up checksums for transactions succeeding T by looking at its transaction logs,
            //    but T needs to be stored in neostore to be accessible. Obviously this scenario is only
            //    problematic as long as we don't migrate and translate old logs.
            TransactionId lastTxInfo = ReadLastTxInformation(migrationStructure);

            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.LAST_TRANSACTION_CHECKSUM, lastTxInfo.Checksum());
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.UPGRADE_TRANSACTION_CHECKSUM, lastTxInfo.Checksum());
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.LAST_TRANSACTION_COMMIT_TIMESTAMP, lastTxInfo.CommitTimestamp());
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.UPGRADE_TRANSACTION_COMMIT_TIMESTAMP, lastTxInfo.CommitTimestamp());

            // add LAST_CLOSED_TRANSACTION_LOG_VERSION and LAST_CLOSED_TRANSACTION_LOG_BYTE_OFFSET to the migrated
            // NeoStore
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.LAST_CLOSED_TRANSACTION_LOG_VERSION, lastClosedTxLogPosition.LogVersion);
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.LAST_CLOSED_TRANSACTION_LOG_BYTE_OFFSET, lastClosedTxLogPosition.ByteOffset);

            // Upgrade version in NeoStore
            MetaDataStore.setRecord(_pageCache, migrationDirNeoStore, MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong(versionToMigrateTo));
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void writeLastTxInformation(org.neo4j.io.layout.DatabaseLayout migrationStructure, org.neo4j.kernel.impl.store.TransactionId txInfo) throws java.io.IOException
        internal virtual void WriteLastTxInformation(DatabaseLayout migrationStructure, TransactionId txInfo)
        {
            WriteTxLogCounters(_fileSystem, LastTxInformationFile(migrationStructure), txInfo.TransactionIdConflict(), txInfo.Checksum(), txInfo.CommitTimestamp());
        }