From a5fb18533e67beea56d8f9f66f1d7f2016c1c94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Tomic=CC=8Cevic=CC=81?= <dominik.tomicevic@gmail.com> Date: Sat, 12 Mar 2016 10:39:10 +0100 Subject: [PATCH] fixed mvcc hints bug --- mvcc/record.hpp | 6 ++++++ mvcc/version_list.hpp | 21 +++++---------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/mvcc/record.hpp b/mvcc/record.hpp index 5395b21c9..3f63bd9d6 100644 --- a/mvcc/record.hpp +++ b/mvcc/record.hpp @@ -92,6 +92,12 @@ public: template <class U> bool committed(U& hints, const Id& id, const tx::Transaction& t) { + // you certainly can't see the transaction with id greater than yours + // as that means it started after this transaction and if it committed, + // it committed after this transaction had started. + if(id > t.id) + return false; + auto hint_bits = hints.load(); // if hints are set, return if xid is committed diff --git a/mvcc/version_list.hpp b/mvcc/version_list.hpp index af7d6beb2..c0e0940fa 100644 --- a/mvcc/version_list.hpp +++ b/mvcc/version_list.hpp @@ -17,6 +17,7 @@ class VersionList : public LazyGC<VersionList<T>> public: using uptr = std::unique_ptr<VersionList<T>>; + using item_t = T; class Accessor { @@ -72,7 +73,7 @@ public: const Id& id() const { - return vlist.identifier; + return vlist.id; } private: @@ -80,14 +81,14 @@ public: VersionList<T>& vlist; }; - VersionList() = default; + VersionList(Id id) : id(id) {} VersionList(const VersionList&) = delete; /* @brief Move constructs the version list * Note: use only at the beginning of the "other's" lifecycle since this * constructor doesn't move the RecordLock, but only the head pointer */ - VersionList(VersionList&& other) + VersionList(VersionList&& other) : id(other.id) { this->head = other.head.load(); this->identifier = other.id(); @@ -130,22 +131,12 @@ public: } - const Id& id() const - { - return identifier; - } - - void id(const Id& identifier) - { - this->identifier = identifier; - } + const Id id; private: std::atomic<T*> head {nullptr}; RecordLock lock; - Id identifier; - //static Recycler recycler; T* find(const tx::Transaction& t) @@ -172,8 +163,6 @@ private: { assert(head == nullptr); - // this->id = id; - // create a first version of the record // TODO replace 'new' with something better auto v1 = new T();