Fix transactions releasing locks

Summary: Locks should be released as early as possible

Reviewers: msantl, florijan

Reviewed By: msantl

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1357
This commit is contained in:
Dominik Gleich 2018-04-12 13:36:15 +02:00
parent 79b9c0a647
commit f26a529a5b

View File

@ -25,15 +25,15 @@ class StorageGcWorker : public StorageGc {
}
void CollectCommitLogGarbage(tx::transaction_id_t oldest_active) final {
// We first need to delete transactions that we can delete to be sure that
// the locks are released as well. Otherwise some new transaction might
// try to acquire a lock which hasn't been released (if the transaction
// cache cleaner was not scheduled at this time), and take a look into the
// commit log which no longer contains that transaction id.
dynamic_cast<tx::WorkerEngine &>(tx_engine_)
.ClearTransactionalCache(oldest_active);
auto safe_to_delete = GetClogSafeTransaction(oldest_active);
if (safe_to_delete) {
// We first need to delete transactions that we can delete to be sure that
// the locks are released as well. Otherwise some new transaction might
// try to aquire a lock which hasn't been released (if the transaction
// cache cleaner was not scheduled at this time), and take a look into the
// commit log which no longer contains that transaction id
dynamic_cast<tx::WorkerEngine &>(tx_engine_)
.ClearTransactionalCache(*safe_to_delete);
master_client_pool_.Call<distributed::RanLocalGcRpc>(*safe_to_delete,
worker_id_);
tx_engine_.GarbageCollectCommitLog(*safe_to_delete);