Esempio n. 1
0
 internal LogTailInformation(CheckPoint lastCheckPoint, bool recordAfterCheckpoint, long firstTxIdAfterLastCheckPoint, long oldestLogVersionFound, long currentLogVersion, LogEntryVersion latestLogEntryVersion)
 {
     this.LastCheckPoint = lastCheckPoint;
     this.FirstTxIdAfterLastCheckPoint = firstTxIdAfterLastCheckPoint;
     this.OldestLogVersionFound        = oldestLogVersionFound;
     this.CurrentLogVersion            = currentLogVersion;
     this.LatestLogEntryVersion        = latestLogEntryVersion;
     this.RecordAfterCheckpoint        = recordAfterCheckpoint;
 }
Esempio n. 2
0
 public CheckPoint(LogEntryVersion version, LogPosition logPosition) : base(version, LogEntryByteCodes.CheckPoint)
 {
     this._logPosition = logPosition;
 }
Esempio n. 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private LogTailInformation findLogTail() throws java.io.IOException
        private LogTailInformation FindLogTail()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long highestLogVersion = logFiles.getHighestLogVersion();
            long            highestLogVersion           = _logFiles.HighestLogVersion;
            long            version                     = highestLogVersion;
            long            versionToSearchForCommits   = highestLogVersion;
            LogEntryStart   latestStartEntry            = null;
            long            oldestStartEntryTransaction = -1;
            long            oldestVersionFound          = -1;
            LogEntryVersion latestLogEntryVersion       = null;
            bool            startRecordAfterCheckpoint  = false;
            bool            corruptedTransactionLogs    = false;

            while (version >= _logFiles.LowestLogVersion && version >= INITIAL_LOG_VERSION)
            {
                oldestVersionFound = version;
                CheckPoint latestCheckPoint = null;
                try
                {
                    using (LogVersionedStoreChannel channel = _logFiles.openForVersion(version), ReadAheadLogChannel readAheadLogChannel = new ReadAheadLogChannel(channel), LogEntryCursor cursor = new LogEntryCursor(_logEntryReader, readAheadLogChannel))
                    {
                        LogEntry entry;
                        long     maxEntryReadPosition = 0;
                        while (cursor.Next())
                        {
                            entry = cursor.Get();

                            // Collect data about latest checkpoint
                            if (entry is CheckPoint)
                            {
                                latestCheckPoint = entry.As();
                            }
                            else if (entry is LogEntryCommit)
                            {
                                if (oldestStartEntryTransaction == NoTransactionId)
                                {
                                    oldestStartEntryTransaction = (( LogEntryCommit )entry).TxId;
                                }
                            }
                            else if (entry is LogEntryStart)
                            {
                                LogEntryStart startEntry = entry.As();
                                if (version == versionToSearchForCommits)
                                {
                                    latestStartEntry = startEntry;
                                }
                                startRecordAfterCheckpoint = true;
                            }

                            // Collect data about latest entry version, only in first log file
                            if (version == versionToSearchForCommits || latestLogEntryVersion == null)
                            {
                                latestLogEntryVersion = entry.Version;
                            }
                            maxEntryReadPosition = readAheadLogChannel.Position();
                        }
                        if (HasUnreadableBytes(channel, maxEntryReadPosition))
                        {
                            corruptedTransactionLogs = true;
                        }
                    }
                }
                catch (Exception e) when(e is Exception || e is ClosedByInterruptException)
                {
                    // These should not be parsing errors
                    throw e;
                }
                catch (Exception t)
                {
                    _monitor.corruptedLogFile(version, t);
                    if (_failOnCorruptedLogFiles)
                    {
                        throwUnableToCleanRecover(t);
                    }
                    corruptedTransactionLogs = true;
                }

                if (latestCheckPoint != null)
                {
                    return(CheckpointTailInformation(highestLogVersion, latestStartEntry, oldestVersionFound, latestLogEntryVersion, latestCheckPoint, corruptedTransactionLogs));
                }

                version--;

                // if we have found no commits in the latest log, keep searching in the next one
                if (latestStartEntry == null)
                {
                    versionToSearchForCommits--;
                }
            }

            return(new LogTailInformation(corruptedTransactionLogs || startRecordAfterCheckpoint, oldestStartEntryTransaction, oldestVersionFound, highestLogVersion, latestLogEntryVersion));
        }
Esempio n. 4
0
 public LogTailInformation(bool recordAfterCheckpoint, long firstTxIdAfterLastCheckPoint, long oldestLogVersionFound, long currentLogVersion, LogEntryVersion latestLogEntryVersion) : this(null, recordAfterCheckpoint, firstTxIdAfterLastCheckPoint, oldestLogVersionFound, currentLogVersion, latestLogEntryVersion)
 {
 }
Esempio n. 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected LogTailInformation checkpointTailInformation(long highestLogVersion, org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart latestStartEntry, long oldestVersionFound, org.neo4j.kernel.impl.transaction.log.entry.LogEntryVersion latestLogEntryVersion, org.neo4j.kernel.impl.transaction.log.entry.CheckPoint latestCheckPoint, boolean corruptedTransactionLogs) throws java.io.IOException
        protected internal virtual LogTailInformation CheckpointTailInformation(long highestLogVersion, LogEntryStart latestStartEntry, long oldestVersionFound, LogEntryVersion latestLogEntryVersion, CheckPoint latestCheckPoint, bool corruptedTransactionLogs)
        {
            LogPosition checkPointLogPosition            = latestCheckPoint.LogPosition;
            ExtractedTransactionRecord transactionRecord = ExtractFirstTxIdAfterPosition(checkPointLogPosition, highestLogVersion);
            long firstTxIdAfterPosition     = transactionRecord.Id;
            bool startRecordAfterCheckpoint = (firstTxIdAfterPosition != NoTransactionId) || ((latestStartEntry != null) && (latestStartEntry.StartPosition.CompareTo(latestCheckPoint.LogPosition) >= 0));
            bool corruptedLogs = transactionRecord.Failure || corruptedTransactionLogs;

            return(new LogTailInformation(latestCheckPoint, corruptedLogs || startRecordAfterCheckpoint, firstTxIdAfterPosition, oldestVersionFound, highestLogVersion, latestLogEntryVersion));
        }