void RocksTransaction::recordSnapshotId() {
     {
         stdx::lock_guard<stdx::mutex> lk(_transactionEngine->_lock);
         _cleanup_inlock();
         _activeSnapshotsIter = _transactionEngine->_getLatestSnapshotId_inlock();
     }
     _snapshotId = *_activeSnapshotsIter;
     _snapshotInitialized = true;
 }
Exemplo n.º 2
0
void RocksTransaction::recordSnapshotId() {
    {
        boost::mutex::scoped_lock lk(_transactionEngine->_lock);
        _cleanup_inlock();
        _activeSnapshotsIter = _transactionEngine->_getLatestSnapshotId_inlock();
    }
    _snapshotId = *_activeSnapshotsIter;
    _snapshotInitialized = true;
}
 void RocksTransaction::abort() {
     if (_writtenKeys.empty() && !_snapshotInitialized) {
         return;
     }
     {
         stdx::lock_guard<stdx::mutex> lk(_transactionEngine->_lock);
         for (const auto& key : _writtenKeys) {
             _transactionEngine->_uncommittedTransactionId.erase(key);
         }
         _cleanup_inlock();
     }
     _writtenKeys.clear();
 }
Exemplo n.º 4
0
void RocksTransaction::commit() {
    if (_writtenKeys.empty()) {
        return;
    }
    uint64_t newSnapshotId = 0;
    {
        boost::mutex::scoped_lock lk(_transactionEngine->_lock);
        for (const auto& key : _writtenKeys) {
            invariant(!_transactionEngine->_isKeyCommittedAfterSnapshot_inlock(key, _snapshotId));
            invariant(_transactionEngine->_uncommittedTransactionId[key] == _transactionId);
            _transactionEngine->_uncommittedTransactionId.erase(key);
        }
        newSnapshotId = _transactionEngine->_latestSnapshotId + 1;
        for (const auto& key : _writtenKeys) {
            _transactionEngine->_registerCommittedKey_inlock(key, newSnapshotId);
        }
        _cleanup_inlock();
        _transactionEngine->_latestSnapshotId = newSnapshotId;
    }
    // cleanup
    _writtenKeys.clear();
}