libfoedus-core
FOEDUS Core Library
|
Persistent status part of Transaction ID. More...
Persistent status part of Transaction ID.
Unlike what [TU13] Sec 4.2 defines, FOEDUS's TID is 128 bit to contain more information. XctId represents a half (64bit) of TID that is used to represent persistent status of the record, such as record versions. The locking-mechanism part is separated to another half; McsWwLock.
Bits | Name | Description |
---|---|---|
1 | Psuedo-delete bit | Whether te key is logically non-existent. |
2 | Moved bit | This is used for the Master-tree foster-twin protocol. when a record is moved from one page to another during split. |
3 | BeingWritten | Before we start applying modifications to a record, we set true to this so that optimistic-read can easily check for half-updated value. After the modification, we set false to this. Of course with appropriate fences. |
4 | NextLayer | This is used only in Masstree. This bit indicates whether the record represents a pointer to next layer. False if it is a tuple itself. We put this information as part of XctId because we sometimes have to transactionally know whether the record is a next-layer pointer or not. There is something wrong if a read-set or write-set contains an XctId whose NextLayer bit is ON, because then the record is not a logical tuple. In other words, a reading transaction can efficiently protect their reads on a record that might become a next-layer pointer with a simple check after the usual read protocol. |
5..32 | Epoch | The recent owning transaction was in this Epoch. We don't consume full 32 bits for epoch. Assuming 20ms per epoch, 28bit still represents 1 year. All epochs will be refreshed by then or we can have some periodic mantainance job to make it sure. |
33..64 | Ordinal | The recent owning transaction had this ordinal in the epoch. We assign 32 bits. Thus we no longer have the case where we have to increment current epoch even when there are many dependencies between transactions. We still have the machanism to do so, but in reality it won't be triggered. |
Definition at line 955 of file xct_id.hpp.
#include <xct_id.hpp>
Public Member Functions | |
XctId () | |
void | set (Epoch::EpochInteger epoch_int, uint32_t ordinal) |
Epoch | get_epoch () const __attribute__((always_inline)) |
void | set_epoch (Epoch epoch) __attribute__((always_inline)) |
Epoch::EpochInteger | get_epoch_int () const __attribute__((always_inline)) |
void | set_epoch_int (Epoch::EpochInteger epoch_int) __attribute__((always_inline)) |
bool | is_valid () const __attribute__((always_inline)) |
uint32_t | get_ordinal () const __attribute__((always_inline)) |
void | set_ordinal (uint32_t ordinal) __attribute__((always_inline)) |
void | increment_ordinal () __attribute__((always_inline)) |
int | compare_epoch_and_orginal (const XctId &other) const __attribute__((always_inline)) |
Returns -1, 0, 1 when this is less than, same, larger than other in terms of epoch/ordinal. More... | |
void | set_being_written () __attribute__((always_inline)) |
void | set_write_complete () __attribute__((always_inline)) |
XctId | spin_while_being_written () const __attribute__((always_inline)) |
Returns a version of this Xid whose being_written flag is off. More... | |
void | set_deleted () __attribute__((always_inline)) |
void | set_notdeleted () __attribute__((always_inline)) |
void | set_moved () __attribute__((always_inline)) |
void | set_next_layer () __attribute__((always_inline)) |
bool | is_being_written () const __attribute__((always_inline)) |
bool | is_deleted () const __attribute__((always_inline)) |
bool | is_moved () const __attribute__((always_inline)) |
bool | is_next_layer () const __attribute__((always_inline)) |
bool | needs_track_moved () const __attribute__((always_inline)) |
is_moved() || is_next_layer() More... | |
bool | operator== (const XctId &other) const __attribute__((always_inline)) |
bool | operator!= (const XctId &other) const __attribute__((always_inline)) |
void | store_max (const XctId &other) __attribute__((always_inline)) |
Kind of std::max(this, other). More... | |
bool | before (const XctId &other) const __attribute__((always_inline)) |
Returns if this XctId is before other in serialization order, meaning this is either an invalid (unused) epoch or strictly less than the other. More... | |
void | clear_status_bits () |
Public Attributes | |
uint64_t | data_ |
Friends | |
std::ostream & | operator<< (std::ostream &o, const XctId &v) |
|
inline |
Definition at line 956 of file xct_id.hpp.
|
inline |
Returns if this XctId is before other in serialization order, meaning this is either an invalid (unused) epoch or strictly less than the other.
Definition at line 1074 of file xct_id.hpp.
References ASSERT_ND, foedus::Epoch::before(), get_epoch(), get_epoch_int(), and get_ordinal().
Referenced by foedus::xct::XctManagerPimpl::precommit_xct_apply(), foedus::xct::Xct::remember_previous_xct_id(), and store_max().
|
inline |
Definition at line 1083 of file xct_id.hpp.
References data_, and foedus::xct::kXctIdMaskSerializer.
Referenced by foedus::xct::XctManagerPimpl::precommit_xct_apply().
|
inline |
Returns -1, 0, 1 when this is less than, same, larger than other in terms of epoch/ordinal.
Definition at line 993 of file xct_id.hpp.
References ASSERT_ND, get_epoch(), get_epoch_int(), get_ordinal(), and foedus::Epoch::is_valid().
Referenced by foedus::storage::hash::HashTmpBin::delete_record(), foedus::storage::hash::HashTmpBin::insert_record(), foedus::storage::hash::HashTmpBin::overwrite_record(), and foedus::storage::hash::HashTmpBin::update_record().
|
inline |
Definition at line 964 of file xct_id.hpp.
References get_epoch_int().
Referenced by foedus::storage::sequential::SequentialStoragePimpl::append_record(), foedus::snapshot::MergeSort::assert_sorted(), before(), compare_epoch_and_orginal(), foedus::storage::sequential::SequentialComposer::compose(), foedus::storage::array::ArrayComposer::drop_root_volatile(), foedus::storage::sequential::SequentialRecordBatch::get_epoch_from_offset(), foedus::storage::sequential::SequentialPage::get_first_record_epoch(), foedus::xct::Xct::issue_next_id(), foedus::xct::operator<<(), foedus::xct::XctManagerPimpl::precommit_xct_apply(), foedus::xct::XctManagerPimpl::precommit_xct_verify_readonly(), foedus::storage::array::prepare_sort_entries(), foedus::storage::hash::prepare_sort_entries(), foedus::storage::masstree::prepare_sort_entries(), foedus::restart::RestartManagerPimpl::redo_meta_logs(), foedus::snapshot::LogReducerRef::verify_log_chunk(), foedus::storage::masstree::MasstreeStoragePimpl::verify_single_thread_border(), and foedus::storage::hash::HashStoragePimpl::verify_single_thread_data().
|
inline |
Definition at line 966 of file xct_id.hpp.
References data_.
Referenced by before(), compare_epoch_and_orginal(), get_epoch(), is_valid(), and foedus::log::on_non_durable_meta_log_found().
|
inline |
Definition at line 976 of file xct_id.hpp.
References ASSERT_ND, and data_.
Referenced by foedus::snapshot::MergeSort::assert_sorted(), before(), compare_epoch_and_orginal(), increment_ordinal(), foedus::xct::Xct::issue_next_id(), foedus::log::on_non_durable_meta_log_found(), foedus::xct::operator<<(), foedus::xct::XctManagerPimpl::precommit_xct_apply(), foedus::storage::array::prepare_sort_entries(), foedus::storage::hash::prepare_sort_entries(), foedus::storage::masstree::prepare_sort_entries(), and foedus::snapshot::LogReducerRef::verify_log_chunk().
|
inline |
Definition at line 984 of file xct_id.hpp.
References get_ordinal(), and set_ordinal().
|
inline |
Definition at line 1038 of file xct_id.hpp.
References data_.
Referenced by foedus::xct::Xct::add_to_read_set(), foedus::xct::LockableXctId::is_being_written(), foedus::xct::RwLockableXctId::is_being_written(), foedus::xct::Xct::on_record_read(), foedus::xct::operator<<(), foedus::storage::sequential::SequentialStorageControlBlock::optimistic_read_truncate_epoch(), foedus::storage::masstree::RecordLocation::populate_logical(), foedus::storage::hash::RecordLocation::populate_logical(), foedus::storage::hash::RecordLocation::populate_physical(), foedus::xct::XctManagerPimpl::precommit_xct_apply(), foedus::xct::XctManagerPimpl::precommit_xct_verify_readonly(), foedus::xct::XctManagerPimpl::precommit_xct_verify_readwrite(), foedus::storage::masstree::MasstreeStoragePimpl::verify_single_thread_border(), and foedus::storage::hash::HashStoragePimpl::verify_single_thread_data().
|
inline |
Definition at line 1040 of file xct_id.hpp.
References data_.
Referenced by foedus::storage::masstree::MasstreeStoragePimpl::delete_general(), foedus::storage::hash::HashStoragePimpl::delete_record(), foedus::storage::hash::HashTmpBin::delete_record(), foedus::storage::masstree::MasstreeStoragePimpl::increment_general(), foedus::storage::hash::HashStoragePimpl::increment_record(), foedus::storage::masstree::MasstreeStoragePimpl::insert_general(), foedus::storage::hash::HashStoragePimpl::insert_record(), foedus::storage::hash::HashTmpBin::insert_record(), foedus::xct::LockableXctId::is_deleted(), foedus::xct::RwLockableXctId::is_deleted(), foedus::storage::masstree::MasstreeCursor::next(), foedus::storage::masstree::MasstreeCursor::open(), foedus::xct::operator<<(), foedus::storage::masstree::MasstreeStoragePimpl::overwrite_general(), foedus::storage::hash::HashStoragePimpl::overwrite_record(), foedus::storage::hash::HashTmpBin::overwrite_record(), foedus::xct::XctManagerPimpl::precommit_xct_apply(), foedus::storage::masstree::MasstreeBorderPage::reserve_initially_next_layer(), foedus::storage::masstree::MasstreeBorderPage::reserve_record_space(), foedus::storage::masstree::MasstreeStoragePimpl::retrieve_general(), foedus::storage::masstree::MasstreeStoragePimpl::retrieve_part_general(), foedus::storage::hash::HashTmpBin::update_record(), foedus::storage::masstree::MasstreeStoragePimpl::upsert_general(), and foedus::storage::hash::HashStoragePimpl::upsert_record().
|
inline |
Definition at line 1041 of file xct_id.hpp.
References data_.
Referenced by foedus::storage::masstree::MasstreeCommonLogType::apply_record_prepare(), foedus::storage::masstree::MasstreeStoragePimpl::follow_layer(), foedus::xct::LockableXctId::is_moved(), foedus::xct::RwLockableXctId::is_moved(), foedus::storage::hash::HashStoragePimpl::locate_record(), foedus::storage::hash::HashStoragePimpl::locate_record_in_snapshot(), foedus::xct::Xct::on_record_read(), foedus::xct::operator<<(), foedus::storage::masstree::RecordLocation::populate_logical(), foedus::storage::hash::RecordLocation::populate_logical(), foedus::storage::masstree::MasstreeStoragePimpl::reserve_record(), foedus::storage::masstree::MasstreeStoragePimpl::reserve_record_normalized(), and foedus::storage::hash::HashDataPage::search_key_physical().
|
inline |
Definition at line 1042 of file xct_id.hpp.
References data_.
Referenced by foedus::xct::Xct::add_to_read_set(), foedus::storage::masstree::MasstreeCommonLogType::apply_record_prepare(), foedus::storage::masstree::MasstreeStoragePimpl::check_next_layer_bit(), foedus::storage::masstree::MasstreeBorderPage::Slot::does_point_to_layer(), foedus::storage::masstree::MasstreeBorderPage::does_point_to_layer(), foedus::storage::masstree::MasstreeStoragePimpl::follow_layer(), foedus::storage::masstree::MasstreeBorderPage::initialize_layer_root(), foedus::xct::LockableXctId::is_next_layer(), foedus::xct::RwLockableXctId::is_next_layer(), foedus::xct::Xct::on_record_read(), foedus::xct::operator<<(), foedus::storage::masstree::RecordLocation::populate_logical(), foedus::storage::hash::RecordLocation::populate_logical(), foedus::storage::hash::RecordLocation::populate_physical(), foedus::storage::masstree::MasstreeBorderPage::reserve_initially_next_layer(), foedus::storage::masstree::MasstreeStoragePimpl::reserve_record(), foedus::storage::masstree::MasstreeBorderPage::track_moved_record_next_layer(), and foedus::storage::masstree::MasstreeStoragePimpl::verify_single_thread_border().
|
inline |
Definition at line 973 of file xct_id.hpp.
References get_epoch_int(), and foedus::Epoch::kEpochInvalid.
Referenced by foedus::xct::Xct::add_to_read_and_write_set(), foedus::storage::array::ArrayStoragePimpl::follow_pointer(), foedus::storage::array::ArrayStoragePimpl::follow_pointers_for_read_batch(), foedus::storage::array::ArrayStoragePimpl::follow_pointers_for_write_batch(), foedus::xct::Xct::initialize(), foedus::xct::Xct::issue_next_id(), foedus::storage::array::ArrayStoragePimpl::locate_record_for_read(), foedus::storage::array::ArrayStoragePimpl::locate_record_for_write(), foedus::storage::array::ArrayStoragePimpl::lookup_for_read(), foedus::storage::array::ArrayStoragePimpl::lookup_for_write(), foedus::storage::masstree::RecordLocation::populate_logical(), foedus::storage::hash::RecordLocation::populate_logical(), foedus::storage::hash::RecordLocation::populate_physical(), and foedus::snapshot::LogReducerRef::verify_log_chunk().
|
inline |
Definition at line 1044 of file xct_id.hpp.
References data_.
Referenced by foedus::xct::LockableXctId::needs_track_moved(), and foedus::xct::RwLockableXctId::needs_track_moved().
|
inline |
|
inline |
|
inline |
Definition at line 958 of file xct_id.hpp.
References ASSERT_ND, data_, and foedus::Epoch::kEpochIntOverflow.
Referenced by foedus::storage::hash::ReserveRecords::create_new_record_in_tail_page(), foedus::storage::masstree::get_initial_xid(), foedus::xct::XctManagerPimpl::precommit_xct_readwrite(), foedus::storage::hash::HashDataPage::reserve_record(), and foedus::storage::sequential::SequentialStoragePimpl::truncate().
|
inline |
Definition at line 1019 of file xct_id.hpp.
References data_, and foedus::xct::kXctIdBeingWrittenBit.
Referenced by foedus::xct::XctManagerPimpl::precommit_xct_apply().
|
inline |
Definition at line 1027 of file xct_id.hpp.
References data_, and foedus::xct::kXctIdDeletedBit.
Referenced by foedus::storage::hash::ReserveRecords::create_new_record_in_tail_page(), foedus::xct::XctManagerPimpl::precommit_xct_apply(), and foedus::storage::hash::HashDataPage::reserve_record().
|
inline |
Definition at line 965 of file xct_id.hpp.
References set_epoch_int().
Referenced by foedus::log::MetaLogBuffer::commit(), foedus::xct::Xct::initialize(), and foedus::xct::Xct::issue_next_id().
|
inline |
Definition at line 969 of file xct_id.hpp.
References ASSERT_ND, data_, and foedus::Epoch::kEpochIntOverflow.
Referenced by set_epoch().
|
inline |
Definition at line 1029 of file xct_id.hpp.
References data_, and foedus::xct::kXctIdMovedBit.
Referenced by foedus::storage::masstree::SplitBorder::run().
|
inline |
Definition at line 1030 of file xct_id.hpp.
References data_, and foedus::xct::kXctIdNextLayerBit.
Referenced by foedus::storage::masstree::MasstreeBorderPage::append_next_layer_snapshot(), and foedus::storage::masstree::MasstreeBorderPage::replace_next_layer_snapshot().
|
inline |
|
inline |
Definition at line 980 of file xct_id.hpp.
References ASSERT_ND, and data_.
Referenced by increment_ordinal(), foedus::xct::Xct::initialize(), and foedus::xct::Xct::issue_next_id().
|
inline |
|
inline |
Returns a version of this Xid whose being_written flag is off.
This internally spins until the bit becomes false, so use it only where deadlock is not possible.
Definition at line 1190 of file xct_id.hpp.
References data_, and UNLIKELY.
Referenced by foedus::xct::Xct::on_record_read(), and foedus::storage::hash::RecordLocation::populate_physical().
|
inline |
Kind of std::max(this, other).
This relies on the semantics of before(). Thus, this can't differentiate two XctId that differ only in status bits. This method is only used for XctId generation at commit time, so that's fine.
Definition at line 1059 of file xct_id.hpp.
References before().
Referenced by foedus::xct::Xct::issue_next_id(), foedus::xct::XctManagerPimpl::precommit_xct_lock(), and foedus::xct::XctManagerPimpl::precommit_xct_verify_readwrite().
|
friend |
Definition at line 178 of file xct_id.cpp.
uint64_t foedus::xct::XctId::data_ |
Definition at line 1087 of file xct_id.hpp.
Referenced by foedus::storage::masstree::RecordLocation::clear(), foedus::storage::hash::RecordLocation::clear(), clear_status_bits(), get_epoch_int(), get_ordinal(), is_being_written(), is_deleted(), is_moved(), is_next_layer(), needs_track_moved(), operator!=(), operator==(), foedus::xct::LockableXctId::reset(), foedus::xct::RwLockableXctId::reset(), set(), set_being_written(), set_deleted(), set_epoch_int(), set_moved(), set_next_layer(), set_notdeleted(), set_ordinal(), set_write_complete(), and spin_while_being_written().