private bool ShouldCheckpoint(TransactionMap txManager, out List <BeginTransactionOperationLogRecord> abortTxList)
        {
            abortTxList = null;

            // There is a checkpoint in progres. So return false
            if (this.logManager.LastInProgressCheckpointRecord != null)
            {
                return(false);
            }

            if (ShouldInitiatePeriodicCheckpoint())
            {
                return(true);
            }

            var bytesUsedFromLastCheckpoint = this.GetBytesUsed(this.logManager.LastCompletedBeginCheckpointRecord);

            // If there is enough data to checkpoint, we should try to look for 'bad' transactions that are preventing
            // enough data from being checkpointed
            if (bytesUsedFromLastCheckpoint <= this.checkpointIntervalBytes)
            {
                return(false);
            }

            var earliestPendingTx = txManager.GetEarliestPendingTransaction();

            // If there is no pending tx, we should checkpoint now
            if (earliestPendingTx == null)
            {
                return(true);
            }

            // The earliest pending tx is very new and it has not yet been flushed. So it is fine to checkpoint
            // This could ALSO imply that we have a really old Tx that has not been flushed and has been lying around in the buffers
            // However, the latter case is taken care of by throttling the incoming operations based on "pending bytes" that are unflushed
            if (earliestPendingTx.RecordPosition == LogRecord.InvalidRecordPosition)
            {
                return(true);
            }

            var oldTxOffset = this.GetCurrentTailPosition() - this.txnAbortThresholdInBytes - 1;

            // The transaction is new enough. We can checkpoint
            if (earliestPendingTx.RecordPosition > oldTxOffset)
            {
                return(true);
            }

            // Get all 'bad' transactions that are preventing us from checkpointing enough state
            // We will return 'false' now and the next group commit should successfully checkpoint since the earliest pending should be newer
            abortTxList = txManager.GetPendingTransactionsOlderThanPosition(oldTxOffset);
            return(false);
        }
        public List <BeginTransactionOperationLogRecord> GetOldTransactions(TransactionMap txManager)
        {
            var tail = this.GetCurrentTailPosition();

            // The tail is smaller than truncate interval
            if (tail <= this.txnAbortThresholdInBytes)
            {
                return(null);
            }

            var oldTxOffset = this.GetCurrentTailPosition() - this.txnAbortThresholdInBytes - 1;

            // Get all 'bad' transactions that are preventing us from checkpointing enough state
            return(txManager.GetPendingTransactionsOlderThanPosition(oldTxOffset));
        }