libfoedus-core
FOEDUS Core Library
|
Transaction Manager, which provides APIs to begin/commit/abort transactions. More...
Transaction Manager, which provides APIs to begin/commit/abort transactions.
This package is the implementation of the commit protocol, the gut of concurrency control.
First thing first. Here's a minimal example to start one transaction in the engine.
Notice the wait_for_commit(commit_epoch) call. Without invoking the method, you should not consider that your transactions are committed. That's why the name of the method invoked above is "precommit_xct".
Here's a minimal example to start several transactions and commit them together, or group-commit, which is the primary usecase our engine is optimized for.
In this case, we invoke wait_for_commit() for the largest commit epoch just once at the end. This dramatically improves the throughput at the cost of latency of individual transactions.
Our commit protocol is based on [TU13], except that we have handling of non-volatile pages. [TU13]'s commit protocol completely avoids writes to shared memory by read operations. [LARSON11] is also an optimistic concurrency control, but it still has "read-lock" bits which has to be written by read operations. In many-core NUMA environment, this might cause scalability issues, thus we employ [TU13]'s approach.
The engine maintains two global foedus::Epoch; current Epoch and durable Epoch. foedus::xct::XctManager keeps advancing current epoch periodically while the log module advances durable epoch when it confirms that all log entries up to the epoch becomes durable and also that the log module durably writes a savepoint ( Savepoint Manager ) file.
Epoch Chime advances the current global epoch when a configured interval elapses or the user explicitly requests it. The chime checks whether it can safely advance an epoch so that the following invariant always holds.
In many cases, the invariants are trivially achieved. However, there are a few tricky cases.
Whenever the chime advances the epoch, we have to safely detect whether there is any transaction that might violate the invariant without causing expensive synchronization. This is done via the in-commit epoch guard. For more details, see the following class.
See foedus::xct::IsolationLevel
bluh
![]() |
Modules | |
Retrospective Lock List | |
Retrospective Lock List (RLL) to avoid deadlocks. | |
Physical-only, short-living system transactions. | |
Files | |
file | fwd.hpp |
Forward declarations of classes in transaction package. | |
file | xct_id.hpp |
Definitions of IDs in this package and a few related constant values. | |
Classes | |
struct | foedus::xct::InCommitEpochGuard |
Automatically sets in-commit-epoch with appropriate fence during pre-commit protocol. More... | |
class | foedus::xct::Xct |
Represents a user transaction. More... | |
struct | foedus::xct::PointerAccess |
Represents a record of following a page pointer during a transaction. More... | |
struct | foedus::xct::PageVersionAccess |
Represents a record of reading a page during a transaction. More... | |
struct | foedus::xct::ReadXctAccess |
Represents a record of read-access during a transaction. More... | |
struct | foedus::xct::WriteXctAccess |
Represents a record of write-access during a transaction. More... | |
struct | foedus::xct::LockFreeReadXctAccess |
Represents a record of special read-access during a transaction without any need for locking. More... | |
struct | foedus::xct::LockFreeWriteXctAccess |
Represents a record of special write-access during a transaction without any need for locking. More... | |
struct | foedus::xct::McsWwLock |
An exclusive-only (WW) MCS lock data structure. More... | |
struct | foedus::xct::McsRwLock |
An MCS reader-writer lock data structure. More... | |
struct | foedus::xct::XctId |
Persistent status part of Transaction ID. More... | |
struct | foedus::xct::LockableXctId |
Transaction ID, a 128-bit data to manage record versions and provide locking mechanism. More... | |
class | foedus::xct::XctManager |
Xct Manager class that provides API to begin/abort/commit transaction. More... | |
class | foedus::xct::XctManagerPimpl |
Pimpl object of XctManager. More... | |
class | foedus::xct::McsAdaptorConcept< RW_BLOCK > |
Defines an adapter template interface for our MCS lock classes. More... | |
class | foedus::xct::McsImpl< ADAPTOR, RW_BLOCK > |
Implements an MCS-locking Algorithm. More... | |
class | foedus::xct::McsWwImpl< ADAPTOR > |
A specialized/simplified implementation of an MCS-locking Algorithm for exclusive-only (WW) locks. More... | |
class | foedus::xct::McsWwOwnerlessImpl |
A ownerless (contextless) interface for McsWwImpl. More... | |
struct | foedus::xct::XctOptions |
Set of options for xct manager. More... | |
Typedefs | |
typedef uintptr_t | foedus::xct::UniversalLockId |
Universally ordered identifier of each lock. More... | |
typedef uint32_t | foedus::xct::LockListPosition |
Index in a lock-list, either RLL or CLL. More... | |
Enumerations | |
enum | foedus::xct::IsolationLevel { foedus::xct::kDirtyRead, foedus::xct::kSnapshot, foedus::xct::kSerializable } |
Specifies the level of isolation during transaction processing. More... | |
enum | foedus::xct::LockMode { foedus::xct::kNoLock = 0, foedus::xct::kReadLock, foedus::xct::kWriteLock } |
Represents a mode of lock. More... | |
Variables | |
const uint64_t | foedus::xct::kMaxXctOrdinal = (1ULL << 24) - 1U |
Maximum value of in-epoch ordinal. More... | |
typedef uint32_t foedus::xct::LockListPosition |
Index in a lock-list, either RLL or CLL.
The value zero is guaranteed to be invalid. So, lock lists using this type must reserve index-0 to be either a dummy entry or some sentinel entry. Thanks to this contract, it's easy to initialize structs holding this type.
Definition at line 148 of file xct_id.hpp.
typedef uintptr_t foedus::xct::UniversalLockId |
Universally ordered identifier of each lock.
This must follow a universally consistent order even across processes.
Currently we assume all locks come from volatile pages. The bits are used as: |–63–48–|–47—0–| |–NodeId–|–Offset–|
NodeId: ID of the NUMA node where this lock is allocated. Offset: the lock VA's offset based off of its owner node's virtual pool's start VA.
We attach the same shmem in fresh new processes in the same order and in the same machine.. most likely we get the same VA-mapping. // ASLR? Turn it off. I don't care security.
So far a unitptr_t, revisit later if we need a struct over a uint64_t. Now we just compare the whole uintptr, which might cause some socket's data are always later; ideally, we can compare only the offset part. Revisit later.
Definition at line 134 of file xct_id.hpp.
Specifies the level of isolation during transaction processing.
May add:
but probably they are superseded either by kDirtyRead or kSnapshot.
Definition at line 55 of file xct_id.hpp.
Represents a mode of lock.
The order is important. The larger lock mode includes the smaller.
Definition at line 95 of file xct_id.hpp.
const uint64_t foedus::xct::kMaxXctOrdinal = (1ULL << 24) - 1U |
Maximum value of in-epoch ordinal.
We reserve 4 bytes in XctId, but in reality 3 bytes are more than enough. By restricting it to within 3 bytes, we can pack more information in a few places.
Definition at line 898 of file xct_id.hpp.
Referenced by foedus::xct::Xct::issue_next_id().