From 29234067d966393246c290d8393b973ff9b0c3a2 Mon Sep 17 00:00:00 2001 From: Dominik Gleich Date: Mon, 9 Apr 2018 11:24:11 +0200 Subject: [PATCH] Call engine tx cache cleanup Summary: After the commit log was cleared there was some transaction that tried to acquire a lock on an object that was taken by a transaction that was not longer active on the worker. Inquring the commit log about that transaction causes a crash since the commit log is cleared of that transaction. Solution is to clear the transaction cache before clearing the commit log, which forces the transactions to release their locks and as such their ids will never be queried through the commit log in the future. Reviewers: florijan, msantl Reviewed By: msantl Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1342 --- src/database/storage_gc_worker.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/database/storage_gc_worker.hpp b/src/database/storage_gc_worker.hpp index a88b201f0..ab8db18f6 100644 --- a/src/database/storage_gc_worker.hpp +++ b/src/database/storage_gc_worker.hpp @@ -4,6 +4,7 @@ #include "database/storage_gc.hpp" #include "distributed/storage_gc_rpc_messages.hpp" +#include "transactions/engine_worker.hpp" #include "transactions/transaction.hpp" namespace database { @@ -19,6 +20,13 @@ class StorageGcWorker : public StorageGc { void CollectCommitLogGarbage(tx::transaction_id_t oldest_active) final { 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_engine_) + .ClearTransactionalCache(*safe_to_delete); master_client_pool_.Call(*safe_to_delete, worker_id_); tx_engine_.GarbageCollectCommitLog(*safe_to_delete);