Пример #1
0
        public void CanRollbackTransaction()
        {
            var startRecord = new StartRecord(_logManager, _bufferManager, 6);

            var lsn = startRecord.WriteToLog();

            _logManager.Flush(lsn);

            _recoveryManager = new RecoveryManager(_bufferManager, _logManager, 6);

            var block  = new Block(RandomFilename, 0);
            var buffer = _bufferManager.Pin(block);

            _recoveryManager.SetInt(buffer, 0, 123);

            Assert.DoesNotThrow(() =>
            {
                _recoveryManager.Rollback();
                _bufferManager.Unpin(buffer);
            });
        }
Пример #2
0
        public void CanRollback()
        {
            _recoveryManager = new RecoveryManager(_bufferManager, _logManager, 6);
            var block = new Block(RandomFilename, 0);

            var buffer = _bufferManager.Pin(block);

            _recoveryManager.Rollback();

            _bufferManager.Unpin(buffer);
            _bufferManager.FlushAll(6);

            var page = _fileManager.ResolvePage();

            _ = page.Read(new Block(_name, 0));

            var enumerator = _logManager.GetEnumerator();

            var record       = enumerator.Current;
            var commitRecord = new RollbackRecord(_logManager, _bufferManager, record);

            Assert.AreEqual(LogRecordType.Rollback, commitRecord.Type);
            Assert.AreEqual(6, commitRecord.TransactionNumber);
        }
Пример #3
0
 public void Rollback()
 {
     _bufferList.UnpinAll();
     _recoveryManager.Rollback();
     _concurrencyManager.Release();
 }