From 3b9d13f1e1eba2dd8143eb83314aba617b7f9f91 Mon Sep 17 00:00:00 2001 From: Teon Banek Date: Fri, 28 Apr 2017 10:33:46 +0200 Subject: [PATCH] Fix errors introduced in D298 Reviewers: florijan, mislav.bradac, mferencevic, buda Reviewed By: florijan Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D326 --- src/mvcc/serialization_error.hpp | 14 -------------- src/mvcc/version_list.hpp | 17 +++++++++++++---- src/threading/sync/futex.hpp | 5 +++-- src/threading/sync/lock_timeout_error.hpp | 11 ----------- src/threading/sync/timed_spinlock.hpp | 2 +- src/transactions/engine.hpp | 6 +++--- tests/unit/mvcc.cpp | 4 ++-- 7 files changed, 22 insertions(+), 37 deletions(-) delete mode 100644 src/mvcc/serialization_error.hpp delete mode 100644 src/threading/sync/lock_timeout_error.hpp diff --git a/src/mvcc/serialization_error.hpp b/src/mvcc/serialization_error.hpp deleted file mode 100644 index c47e44c80..000000000 --- a/src/mvcc/serialization_error.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "utils/exceptions/basic_exception.hpp" - -class SerializationError : public BasicException { - static constexpr const char* default_message = - "Can't serialize due to\ - concurrent operation(s)"; - - public: - SerializationError() : BasicException(default_message) {} - - SerializationError(const std::string& message) : BasicException(message) {} -}; diff --git a/src/mvcc/version_list.hpp b/src/mvcc/version_list.hpp index 5d0b2495b..877be31b8 100644 --- a/src/mvcc/version_list.hpp +++ b/src/mvcc/version_list.hpp @@ -2,16 +2,25 @@ #include +#include "memory/lazy_gc.hpp" +#include "storage/locking/record_lock.hpp" #include "threading/sync/lockable.hpp" #include "transactions/transaction.hpp" - -#include "memory/lazy_gc.hpp" -#include "mvcc/serialization_error.hpp" -#include "storage/locking/record_lock.hpp" #include "utils/assert.hpp" +#include "utils/exceptions.hpp" namespace mvcc { +class SerializationError : public utils::BasicException { + static constexpr const char* default_message = + "Can't serialize due to\ + concurrent operation(s)"; + + public: + using utils::BasicException::BasicException; + SerializationError() : BasicException(default_message) {} +}; + template class VersionList { public: diff --git a/src/threading/sync/futex.hpp b/src/threading/sync/futex.hpp index 4a73694a9..d569a0cf7 100644 --- a/src/threading/sync/futex.hpp +++ b/src/threading/sync/futex.hpp @@ -8,7 +8,8 @@ #include #include #include -#include "lock_timeout_error.hpp" + +#include "threading/sync/lock_timeout_exception.hpp" #include "utils/cpu_relax.hpp" namespace sys { @@ -90,7 +91,7 @@ class Futex { // check if we woke up because of a timeout if (status == -1 && errno == ETIMEDOUT) - throw LockTimeoutError("Lock timeout"); + throw LockTimeoutException("Lock timeout"); } } diff --git a/src/threading/sync/lock_timeout_error.hpp b/src/threading/sync/lock_timeout_error.hpp deleted file mode 100644 index 5460b0dc9..000000000 --- a/src/threading/sync/lock_timeout_error.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// -// Created by buda on 18/02/17. -// -#pragma once - -#include "utils/exceptions/basic_exception.hpp" - -class LockTimeoutError : public BasicException { - public: - using BasicException::BasicException; -}; diff --git a/src/threading/sync/timed_spinlock.hpp b/src/threading/sync/timed_spinlock.hpp index 6799d411b..760b7405d 100644 --- a/src/threading/sync/timed_spinlock.hpp +++ b/src/threading/sync/timed_spinlock.hpp @@ -5,7 +5,7 @@ #include #include -#include "lock_timeout_exception.hpp" +#include "threading/sync/lock_timeout_exception.hpp" template class TimedSpinLock { diff --git a/src/transactions/engine.hpp b/src/transactions/engine.hpp index 9f5318f3f..c03da8561 100644 --- a/src/transactions/engine.hpp +++ b/src/transactions/engine.hpp @@ -10,13 +10,13 @@ #include "transactions/transaction.hpp" #include "transactions/transaction_store.hpp" #include "utils/counters/simple_counter.hpp" -#include "utils/exceptions/basic_exception.hpp" +#include "utils/exceptions.hpp" namespace tx { -class TransactionError : public BasicException { +class TransactionError : public utils::BasicException { public: - using BasicException::BasicException; + using utils::BasicException::BasicException; }; // max value that could be stored as a command id diff --git a/tests/unit/mvcc.cpp b/tests/unit/mvcc.cpp index 2fbc6dfbd..6274a0c44 100644 --- a/tests/unit/mvcc.cpp +++ b/tests/unit/mvcc.cpp @@ -23,7 +23,7 @@ TEST(MVCC, Case1Test3) { auto t4 = engine.begin(); version_list.update(*t4); t4->commit(); - EXPECT_THROW(version_list.remove(*t3), SerializationError); + EXPECT_THROW(version_list.remove(*t3), mvcc::SerializationError); } TEST(MVCC, InSnapshotSerializationError) { @@ -37,7 +37,7 @@ TEST(MVCC, InSnapshotSerializationError) { auto t3 = engine.begin(); // t2 is in snapshot of t3 t2->commit(); - EXPECT_THROW(version_list.update(*t3), SerializationError); + EXPECT_THROW(version_list.update(*t3), mvcc::SerializationError); } // Check that we don't delete records when we re-link.