Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Clone in Desktop Download ZIP

Loading…

Release Row Locks when necessary, Transaction API variant #105

Closed
spetrunia opened this Issue · 0 comments

2 participants

@spetrunia
Collaborator

MyRocks needs to release row locks in some cases:

  1. When a statement is aborted, all the locks it has taken should be released.
  2. SQL may call handler::unlock_row(). This should release the lock(s) that were taken for the last row that was read.

All locks are recursive. A lock may be acquired multiple times. When MyRocks wants to release locks taken by the statement, it only means un-doing the locking actions done by this statement. All the locking done before the last statement must remain.

Releasing locks for failed statement

(Current implementation in MyRocks was done in issue #57).

When a statement inside a transaction fails, MyRocks will make these calls:

   txn->SetSavePoint();  // Called when a statement starts

   ... statement actions like txn->Put(), txn->Delete(), txn->GetForUpdate()

   txn->RollbackToSavePoint();  // Called if the statement failed.

As far as I understood Antony @agiardullo 's suggestion, it was:

Make txn->RollbackToSavePoint() also undo all locking actions done since the last txn->SetSavePoint() call.

This will work.

Release of the last acquired lock

This is used to release the lock that was obtained when reading the last row. From MyRocks point of view, it is sufficient if this TransactionDBImpl 's function was exposed in TransactionDB class:

  void UnLock(TransactionImpl* txn, uint32_t cfh_id, const std::string& key);

MyRocks always knows which Column Family was used, and the key is saved in ha_rocksdb::last_rowkey.

However, current implementation in TransactionDBImpl::UnLock is not sufficient. As far as I understand it is not recursive: one can call TryLock() multiple times, and then a single UnLock() call will fully release the lock. MyRocks needs last UnLock() call to only undo the effect of the last TryLock() call.

@hermanlee hermanlee closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.