fixed commit log singleton bug
This commit is contained in:
parent
a4fb7b60b1
commit
a876efd3f8
@ -8,9 +8,6 @@
|
||||
#include "cypher/common.hpp"
|
||||
#include "utils/terminate_handler.hpp"
|
||||
|
||||
// dumping ground for all kind of visitors
|
||||
#include "query_engine/traverser/create_traverser.hpp"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
@ -33,10 +30,8 @@ int main(int argc, char *argv[])
|
||||
// traversers
|
||||
auto traverser = get_argument(arguments, "-t", "code");
|
||||
auto print_traverser = Traverser::sptr(new PrintVisitor(cout));
|
||||
auto create_traverser = Traverser::sptr(new CreateTraverser());
|
||||
std::map<std::string, Traverser::sptr> traversers = {
|
||||
{"print", print_traverser},
|
||||
{"create", create_traverser}
|
||||
{"print", print_traverser}
|
||||
};
|
||||
|
||||
cypher::Compiler compiler;
|
||||
|
@ -17,7 +17,7 @@ class DynamicBitset : Lockable<SpinLock>
|
||||
Block(Block&&) = delete;
|
||||
|
||||
static constexpr size_t size = sizeof(block_t) * 8;
|
||||
|
||||
|
||||
constexpr block_t bitmask(size_t group_size) const
|
||||
{
|
||||
return (block_t)(-1) >> (size - group_size);
|
||||
@ -32,7 +32,7 @@ class DynamicBitset : Lockable<SpinLock>
|
||||
void set(size_t k, size_t n, std::memory_order order)
|
||||
{
|
||||
assert(k + n - 1 < size);
|
||||
block.fetch_or(bitmask(n) << k, order);
|
||||
block.fetch_or(bitmask(n) << k, order);
|
||||
}
|
||||
|
||||
void clear(size_t k, size_t n, std::memory_order order)
|
||||
@ -40,7 +40,7 @@ class DynamicBitset : Lockable<SpinLock>
|
||||
assert(k + n - 1 < size);
|
||||
block.fetch_and(~(bitmask(n) << k), order);
|
||||
}
|
||||
|
||||
|
||||
std::atomic<block_t> block {0};
|
||||
};
|
||||
|
||||
@ -136,7 +136,7 @@ private:
|
||||
// lock to prevent others that also want to create a new chunk
|
||||
// from creating it
|
||||
auto guard = acquire_unique();
|
||||
|
||||
|
||||
// double-check locking. if the chunk exists now, some other thread
|
||||
// has just created it, continue searching for my chunk
|
||||
if(chunk->next.load() != nullptr)
|
||||
|
@ -1,9 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <iostream>
|
||||
|
||||
#include "transactions/transaction.hpp"
|
||||
#include "transactions/commit_log.hpp"
|
||||
#include "transactions/engine.hpp"
|
||||
|
||||
#include "mvcc/id.hpp"
|
||||
#include "cre_exp.hpp"
|
||||
#include "version.hpp"
|
||||
@ -110,8 +113,7 @@ public:
|
||||
return false;
|
||||
|
||||
// - you are the first one to check since it ended, consult commit log
|
||||
auto& clog = tx::CommitLog::get();
|
||||
auto info = clog.fetch_info(id);
|
||||
auto info = t.engine.clog.fetch_info(id);
|
||||
|
||||
if(info.is_committed())
|
||||
return hints.set_committed(), true;
|
||||
|
@ -47,12 +47,6 @@ public:
|
||||
|
||||
CommitLog operator=(CommitLog) = delete;
|
||||
|
||||
static CommitLog& get()
|
||||
{
|
||||
static CommitLog log;
|
||||
return log;
|
||||
}
|
||||
|
||||
Info fetch_info(const Id& id)
|
||||
{
|
||||
return Info { log.at(2 * id, 2) };
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "commit_log.hpp"
|
||||
|
||||
#include "utils/counters/simple_counter.hpp"
|
||||
|
||||
#include "threading/sync/spinlock.hpp"
|
||||
#include "threading/sync/lockable.hpp"
|
||||
|
||||
@ -59,7 +58,7 @@ public:
|
||||
void commit(const Transaction& t)
|
||||
{
|
||||
auto guard = this->acquire_unique();
|
||||
CommitLog::get().set_committed(t.id);
|
||||
clog.set_committed(t.id);
|
||||
|
||||
finalize(t);
|
||||
}
|
||||
@ -67,7 +66,7 @@ public:
|
||||
void abort(const Transaction& t)
|
||||
{
|
||||
auto guard = this->acquire_unique();
|
||||
CommitLog::get().set_aborted(t.id);
|
||||
clog.set_aborted(t.id);
|
||||
|
||||
finalize(t);
|
||||
}
|
||||
@ -92,6 +91,8 @@ public:
|
||||
return active.size();
|
||||
}
|
||||
|
||||
CommitLog clog;
|
||||
|
||||
private:
|
||||
void finalize(const Transaction& t)
|
||||
{
|
||||
|
@ -44,8 +44,9 @@ public:
|
||||
void commit();
|
||||
void abort();
|
||||
|
||||
private:
|
||||
Engine& engine;
|
||||
|
||||
private:
|
||||
LockStore<RecordLock> locks;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user