示例#1
0
	    internal void HandleDataDiskFullException(DiskFullException exception)
	    {
			if(_options.ManualFlushing)
				return;

		    _cancellationTokenSource.Cancel();
			_endOfDiskSpace = new EndOfDiskSpaceEvent(exception.DriveInfo);
	    }
示例#2
0
        public Transaction NewTransaction(TransactionFlags flags, TimeSpan? timeout = null)
        {
            bool txLockTaken = false;
	        try
	        {
		        if (flags == (TransactionFlags.ReadWrite))
		        {
			        var wait = timeout ?? (Debugger.IsAttached ? TimeSpan.FromMinutes(30) : TimeSpan.FromSeconds(30));
					Monitor.TryEnter(_txWriter, wait, ref txLockTaken);
					if (txLockTaken == false)
					{
						throw new TimeoutException("Waited for " + wait +
													" for transaction write lock, but could not get it");
					}
					
			        if (_endOfDiskSpace != null)
			        {
				        if (_endOfDiskSpace.CanContinueWriting)
				        {
					        var flushingTask = _flushingTask;
					        Debug.Assert(flushingTask != null && (flushingTask.Status == TaskStatus.Canceled || flushingTask.Status == TaskStatus.RanToCompletion));
					        _cancellationTokenSource = new CancellationTokenSource();
					        _flushingTask = FlushWritesToDataFileAsync();
					        _endOfDiskSpace = null;
				        }
			        }
		        }

		        Transaction tx;

		        _txCommit.EnterReadLock();
		        try
		        {
			        long txId = flags == TransactionFlags.ReadWrite ? _transactionsCounter + 1 : _transactionsCounter;
			        tx = new Transaction(this, txId, flags, _freeSpaceHandling);

			        if (IsDebugRecording)
			        {
				        RecordTransactionState(tx, DebugActionType.TransactionStart);
				        tx.RecordTransactionState = RecordTransactionState;
			        }
		        }
		        finally
		        {
			        _txCommit.ExitReadLock();
		        }

		        _activeTransactions.Add(tx);
		        var state = _dataPager.TransactionBegan();
		        tx.AddPagerState(state);

		        if (flags == TransactionFlags.ReadWrite)
		        {
			        tx.AfterCommit = TransactionAfterCommit;
		        }

		        return tx;
	        }
            catch (Exception)
            {
                if (txLockTaken)
					Monitor.Exit(_txWriter);
                throw;
            }
        }