libfoedus-core
FOEDUS Core Library
|
Xct Manager class that provides API to begin/abort/commit transaction. More...
Xct Manager class that provides API to begin/abort/commit transaction.
Client programs should first call begin_xct(), then either call abort_xct() or precommit_xct(). In the latter case, the client programs should either keep running other transactions without returning the results to users, or call wait_for_commit() to immediately return the results.
Definition at line 35 of file xct_manager.hpp.
#include <xct_manager.hpp>
Public Member Functions | |
XctManager (Engine *engine) | |
~XctManager () | |
XctManager ()=delete | |
XctManager (const XctManager &)=delete | |
XctManager & | operator= (const XctManager &)=delete |
ErrorStack | initialize () override |
Acquires resources in this object, usually called right after constructor. More... | |
bool | is_initialized () const override |
Returns whether the object has been already initialized or not. More... | |
ErrorStack | uninitialize () override |
An idempotent method to release all resources of this object, if any. More... | |
Epoch | get_current_global_epoch () const |
Returns the current global epoch, the epoch a newly started transaction will be in. More... | |
Epoch | get_current_global_epoch_weak () const |
Epoch | get_current_grace_epoch () const |
Returns the current grace-period epoch (global epoch - 1), the epoch some transaction might be still in (though rare). More... | |
Epoch | get_current_grace_epoch_weak () const |
void | wait_for_current_global_epoch (Epoch target_epoch, int64_t wait_microseconds=-1) |
Passively wait until the current global epoch becomes the given value. More... | |
void | advance_current_global_epoch () |
Requests to advance the current global epoch as soon as possible and blocks until it actually does. More... | |
ErrorCode | begin_xct (thread::Thread *context, IsolationLevel isolation_level) |
Begins a new transaction on the thread. More... | |
ErrorCode | precommit_xct (thread::Thread *context, Epoch *commit_epoch) |
Prepares the currently running transaction on the thread for commit. More... | |
ErrorCode | wait_for_commit (Epoch commit_epoch, int64_t wait_microseconds=-1) |
Synchronously blocks until the durable global epoch reaches the given commit epoch or the given duration elapses. More... | |
ErrorCode | abort_xct (thread::Thread *context) |
Aborts the currently running transaction on the thread. More... | |
void | pause_accepting_xct () |
Pause all begin_xct until you call resume_accepting_xct() More... | |
void | resume_accepting_xct () |
Make sure you call this after pause_accepting_xct(). More... | |
![]() | |
virtual | ~Initializable () |
|
explicit |
Definition at line 22 of file xct_manager.cpp.
foedus::xct::XctManager::~XctManager | ( | ) |
Definition at line 25 of file xct_manager.cpp.
|
delete |
|
delete |
ErrorCode foedus::xct::XctManager::abort_xct | ( | thread::Thread * | context | ) |
Aborts the currently running transaction on the thread.
[in,out] | context | Thread context |
Definition at line 82 of file xct_manager_pimpl.cpp.
References foedus::xct::XctManagerPimpl::abort_xct().
void foedus::xct::XctManager::advance_current_global_epoch | ( | ) |
Requests to advance the current global epoch as soon as possible and blocks until it actually does.
This method is used when some thread immediately needs the next epoch for some reason, eg transactional threads ran out of ordinal (per-thread/epoch identifier) in the epoch.
Definition at line 70 of file xct_manager_pimpl.cpp.
References foedus::xct::XctManagerPimpl::advance_current_global_epoch().
Referenced by foedus::log::MetaLogBuffer::commit(), foedus::thread::ThreadPimpl::flush_retired_volatile_page(), foedus::cache::CacheManagerPimpl::handle_cleaner(), and foedus::xct::Xct::issue_next_id().
ErrorCode foedus::xct::XctManager::begin_xct | ( | thread::Thread * | context, |
IsolationLevel | isolation_level | ||
) |
Begins a new transaction on the thread.
[in,out] | context | Thread context |
[in] | isolation_level | concurrency isolation level of the new transaction |
Definition at line 75 of file xct_manager_pimpl.cpp.
References foedus::xct::XctManagerPimpl::begin_xct().
Epoch foedus::xct::XctManager::get_current_global_epoch | ( | ) | const |
Returns the current global epoch, the epoch a newly started transaction will be in.
Definition at line 57 of file xct_manager_pimpl.cpp.
References foedus::xct::XctManagerPimpl::get_current_global_epoch().
Referenced by foedus::log::MetaLogBuffer::commit(), foedus::thread::ThreadPimpl::flush_retired_volatile_page(), foedus::Engine::get_current_global_epoch(), foedus::cache::CacheManagerPimpl::handle_cleaner(), foedus::xct::Xct::issue_next_id(), and foedus::savepoint::SavepointManagerPimpl::savepoint_main().
Epoch foedus::xct::XctManager::get_current_global_epoch_weak | ( | ) | const |
Definition at line 60 of file xct_manager_pimpl.cpp.
References foedus::xct::XctManagerPimpl::get_current_global_epoch_weak().
Referenced by foedus::thread::ThreadPimpl::collect_retired_volatile_page(), and foedus::xct::Xct::issue_next_id().
Epoch foedus::xct::XctManager::get_current_grace_epoch | ( | ) | const |
Returns the current grace-period epoch (global epoch - 1), the epoch some transaction might be still in (though rare).
Definition at line 63 of file xct_manager_pimpl.cpp.
References foedus::xct::XctManagerPimpl::get_current_global_epoch(), and foedus::Epoch::one_less().
Referenced by foedus::Engine::get_current_grace_epoch(), and foedus::storage::sequential::SequentialCursor::SequentialCursor().
Epoch foedus::xct::XctManager::get_current_grace_epoch_weak | ( | ) | const |
Definition at line 66 of file xct_manager_pimpl.cpp.
References foedus::xct::XctManagerPimpl::get_current_global_epoch_weak(), and foedus::Epoch::one_less().
|
overridevirtual |
Acquires resources in this object, usually called right after constructor.
If and only if the return value was not an error, is_initialized() will return TRUE. This method is usually not idempotent, but some implementation can choose to be. In that case, the implementation class should clarify that it's idempotent. This method is responsible for releasing all acquired resources when initialization fails. This method itself is NOT thread-safe. Do not call this in a racy situation.
Implements foedus::Initializable.
Definition at line 30 of file xct_manager.cpp.
References foedus::DefaultInitializable::initialize().
|
overridevirtual |
Returns whether the object has been already initialized or not.
Implements foedus::Initializable.
Definition at line 31 of file xct_manager.cpp.
References foedus::DefaultInitializable::is_initialized().
Referenced by foedus::cache::CacheManagerPimpl::handle_cleaner(), foedus::restart::RestartManagerPimpl::initialize_once(), and foedus::restart::RestartManagerPimpl::uninitialize_once().
|
delete |
void foedus::xct::XctManager::pause_accepting_xct | ( | ) |
Pause all begin_xct until you call resume_accepting_xct()
Definition at line 33 of file xct_manager.cpp.
References foedus::xct::XctManagerPimpl::pause_accepting_xct().
Referenced by foedus::snapshot::SnapshotManagerPimpl::drop_volatile_pages().
ErrorCode foedus::xct::XctManager::precommit_xct | ( | thread::Thread * | context, |
Epoch * | commit_epoch | ||
) |
Prepares the currently running transaction on the thread for commit.
[in,out] | context | Thread context |
[out] | commit_epoch | When successfully prepared, this value indicates the commit epoch of the prepared transaction. When the global epoch reaches this value, the transaction is deemed as committed. |
As the name of this method implies, this method is NOT a commit yet. The transaction is deemed as committed only when the durable global epoch reaches the returned commit epoch. This method merely prepares this transaction to be committed so that the caller can choose either moving on to other transactions in the meantime or to immediately wait for the commit using wait_for_commit().
Definition at line 79 of file xct_manager_pimpl.cpp.
References foedus::xct::XctManagerPimpl::precommit_xct().
void foedus::xct::XctManager::resume_accepting_xct | ( | ) |
Make sure you call this after pause_accepting_xct().
Definition at line 34 of file xct_manager.cpp.
References foedus::xct::XctManagerPimpl::resume_accepting_xct().
Referenced by foedus::snapshot::SnapshotManagerPimpl::drop_volatile_pages().
|
overridevirtual |
An idempotent method to release all resources of this object, if any.
After this method, is_initialized() will return FALSE. Whether this method encounters an error or not, the implementation should make the best effort to release as many resources as possible. In other words, Do not leak all resources because of one issue. This method itself is NOT thread-safe. Do not call this in a racy situation.
Implements foedus::Initializable.
Definition at line 32 of file xct_manager.cpp.
References foedus::DefaultInitializable::uninitialize().
ErrorCode foedus::xct::XctManager::wait_for_commit | ( | Epoch | commit_epoch, |
int64_t | wait_microseconds = -1 |
||
) |
Synchronously blocks until the durable global epoch reaches the given commit epoch or the given duration elapses.
[in] | commit_epoch | Returns kRetOk iff the durable global epoch reaches this value. |
[in] | wait_microseconds | Or, returns a TIMEOUT error when this duration elapses, whichever comes first. Negative value means waiting forever. 0 means conditional, immediately returning without blocking, which is useful to quickly check the committed-ness. |
Client programs can either call this method for each transaction right after precommit_xct() or call this method after a bunch of precommit_xct() calls (group-commit). In either case, remember that both read-only and read-write transactions must not return results to clients until the durable global epoch reaches the given commit epoch. Otherwise, you violate serializability (which might be okay depending on your desired isolation level).
Definition at line 71 of file xct_manager_pimpl.cpp.
References foedus::xct::XctManagerPimpl::wait_for_commit().
void foedus::xct::XctManager::wait_for_current_global_epoch | ( | Epoch | target_epoch, |
int64_t | wait_microseconds = -1 |
||
) |
Passively wait until the current global epoch becomes the given value.
Definition at line 35 of file xct_manager.cpp.
References foedus::xct::XctManagerPimpl::wait_for_current_global_epoch().
Referenced by foedus::cache::CacheManagerPimpl::handle_cleaner().