The rest of core engine exceptions are extended from the BasicException (because of the error handling in the communication stack). Maximum value of the MVCC command id is calculated in the compile time.

Summary:
The rest of core engine exceptions are extended from the BasicException (because of the error handling in the communication stack). Maximum value of the MVCC command id is calculated in the compile time.

I've put the tasks to implement concurrent tests in the qa repo in the backlog. Hopefully they will be implemented within this sprint.

Reviewers: mislav.bradac, mferencevic, florijan

Reviewed By: mislav.bradac

Subscribers: dgleich, pullbot, buda

Differential Revision: https://phabricator.memgraph.io/D298
This commit is contained in:
Marko Budiselic 2017-04-27 12:55:15 -04:00
parent 78af8c8339
commit e6191eadb4
6 changed files with 21 additions and 26 deletions

View File

@ -128,7 +128,7 @@ State StateExecutorRun(Session &session) {
{"message",
"An unknown exception occured, please contact your database "
"administrator."}});
logger.debug("Unknown exception!!!");
logger.debug("std::exception {}", e.what());
if (!fail_sent) {
logger.debug("Couldn't send failure message!");
return State::Close;

View File

@ -1,11 +0,0 @@
#pragma once
#include <stdexcept>
namespace mvcc {
class MvccError : public std::runtime_error {
public:
using runtime_error::runtime_error;
};
}

View File

@ -1,14 +1,14 @@
#pragma once
#include <stdexcept>
#include "utils/exceptions/basic_exception.hpp"
class SerializationError : public std::runtime_error {
class SerializationError : public BasicException {
static constexpr const char* default_message =
"Can't serialize due to\
concurrent operation(s)";
public:
SerializationError() : runtime_error(default_message) {}
SerializationError() : BasicException(default_message) {}
SerializationError(const std::string& message) : runtime_error(message) {}
SerializationError(const std::string& message) : BasicException(message) {}
};

View File

@ -3,9 +3,9 @@
//
#pragma once
#include <stdexcept>
#include "utils/exceptions/basic_exception.hpp"
class LockTimeoutError : public std::runtime_error {
class LockTimeoutError : public BasicException {
public:
using runtime_error::runtime_error;
using BasicException::BasicException;
};

View File

@ -1,6 +1,7 @@
#pragma once
#include <atomic>
#include <limits>
#include <vector>
#include "threading/sync/lockable.hpp"
@ -9,14 +10,19 @@
#include "transactions/transaction.hpp"
#include "transactions/transaction_store.hpp"
#include "utils/counters/simple_counter.hpp"
#include "utils/exceptions/basic_exception.hpp"
namespace tx {
class TransactionError : std::runtime_error {
class TransactionError : public BasicException {
public:
using std::runtime_error::runtime_error;
using BasicException::BasicException;
};
// max value that could be stored as a command id
static constexpr auto kMaxCommandId =
std::numeric_limits<decltype(std::declval<Transaction>().cid)>::max();
class Engine : Lockable<SpinLock> {
public:
using sptr = std::shared_ptr<Engine>;
@ -45,12 +51,12 @@ class Engine : Lockable<SpinLock> {
auto *t = store.get(id);
if (t == nullptr) throw TransactionError("transaction does not exist");
// this is a new command
if (t->cid == 255)
if (t == nullptr) throw TransactionError("Transaction does not exist.");
if (t->cid == kMaxCommandId)
throw TransactionError(
"Reached maximum number of commands in this transaction.");
// this is a new command
t->cid++;
return *t;

View File

@ -46,7 +46,7 @@ class Transaction {
const Id id;
// index of the current command in the current transaction;
uint8_t cid;
uint64_t cid;
Engine &engine;