libfoedus-core
FOEDUS Core Library
foedus::xct::XctManager Class Referencefinal

Xct Manager class that provides API to begin/abort/commit transaction. More...

Detailed Description

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>

Inheritance diagram for foedus::xct::XctManager:
Collaboration diagram for foedus::xct::XctManager:

Public Member Functions

 XctManager (Engine *engine)
 
 ~XctManager ()
 
 XctManager ()=delete
 
 XctManager (const XctManager &)=delete
 
XctManageroperator= (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...
 
- Public Member Functions inherited from foedus::Initializable
virtual ~Initializable ()
 

Constructor & Destructor Documentation

foedus::xct::XctManager::XctManager ( Engine engine)
explicit

Definition at line 22 of file xct_manager.cpp.

22  : pimpl_(nullptr) {
23  pimpl_ = new XctManagerPimpl(engine);
24 }
foedus::xct::XctManager::~XctManager ( )

Definition at line 25 of file xct_manager.cpp.

25  {
26  delete pimpl_;
27  pimpl_ = nullptr;
28 }
foedus::xct::XctManager::XctManager ( )
delete
foedus::xct::XctManager::XctManager ( const XctManager )
delete

Member Function Documentation

ErrorCode foedus::xct::XctManager::abort_xct ( thread::Thread context)

Aborts the currently running transaction on the thread.

Parameters
[in,out]contextThread context
Precondition
context->is_running_xct() == true

Definition at line 82 of file xct_manager_pimpl.cpp.

References foedus::xct::XctManagerPimpl::abort_xct().

82 { return pimpl_->abort_xct(context); }
ErrorCode abort_xct(thread::Thread *context)

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorCode foedus::xct::XctManager::begin_xct ( thread::Thread context,
IsolationLevel  isolation_level 
)

Begins a new transaction on the thread.

Parameters
[in,out]contextThread context
[in]isolation_levelconcurrency isolation level of the new transaction
Precondition
context->is_running_xct() == false

Definition at line 75 of file xct_manager_pimpl.cpp.

References foedus::xct::XctManagerPimpl::begin_xct().

75  {
76  return pimpl_->begin_xct(context, isolation_level);
77 }
ErrorCode begin_xct(thread::Thread *context, IsolationLevel isolation_level)
User transactions related methods.

Here is the call graph for this function:

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().

57  {
58  return pimpl_->get_current_global_epoch();
59 }

Here is the call graph for this function:

Here is the caller graph for this function:

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().

60  {
61  return pimpl_->get_current_global_epoch_weak();
62 }
Epoch get_current_global_epoch_weak() const

Here is the call graph for this function:

Here is the caller graph for this function:

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().

63  {
64  return pimpl_->get_current_global_epoch().one_less();
65 }
Epoch one_less() const
Definition: epoch.hpp:122

Here is the call graph for this function:

Here is the caller graph for this function:

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().

66  {
67  return pimpl_->get_current_global_epoch_weak().one_less();
68 }
Epoch one_less() const
Definition: epoch.hpp:122
Epoch get_current_global_epoch_weak() const

Here is the call graph for this function:

ErrorStack foedus::xct::XctManager::initialize ( )
overridevirtual

Acquires resources in this object, usually called right after constructor.

Precondition
is_initialized() == FALSE

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().

30 { return pimpl_->initialize(); }
ErrorStack initialize() override final
Typical implementation of Initializable::initialize() that provides initialize-once semantics...

Here is the call graph for this function:

bool foedus::xct::XctManager::is_initialized ( ) const
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().

31 { return pimpl_->is_initialized(); }
bool is_initialized() const override final
Returns whether the object has been already initialized or not.

Here is the call graph for this function:

Here is the caller graph for this function:

XctManager& foedus::xct::XctManager::operator= ( const XctManager )
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().

33 { pimpl_->pause_accepting_xct(); }
void pause_accepting_xct()
Pause all begin_xct until you call resume_accepting_xct()

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorCode foedus::xct::XctManager::precommit_xct ( thread::Thread context,
Epoch commit_epoch 
)

Prepares the currently running transaction on the thread for commit.

Precondition
context->is_running_xct() == true
Parameters
[in,out]contextThread context
[out]commit_epochWhen 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().

See also
wait_for_commit()

Definition at line 79 of file xct_manager_pimpl.cpp.

References foedus::xct::XctManagerPimpl::precommit_xct().

79  {
80  return pimpl_->precommit_xct(context, commit_epoch);
81 }
ErrorCode precommit_xct(thread::Thread *context, Epoch *commit_epoch)
This is the gut of commit protocol.

Here is the call graph for this function:

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().

34 { pimpl_->resume_accepting_xct(); }
void resume_accepting_xct()
Make sure you call this after pause_accepting_xct().

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::xct::XctManager::uninitialize ( )
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.

Attention
This method is NOT automatically called from the destructor. This is due to the fundamental limitation in C++. Explicitly call this method as soon as you are done, checking the returned value. You can also use UninitializeGuard to ameliorate the issue, but it's not perfect.
Returns
The error this method encounters, if any. In case there are multiple errors while uninitialization, the implementation should use ErrorStackBatch to produce a batched ErrorStack object.

Implements foedus::Initializable.

Definition at line 32 of file xct_manager.cpp.

References foedus::DefaultInitializable::uninitialize().

32 { return pimpl_->uninitialize(); }
ErrorStack uninitialize() override final
Typical implementation of Initializable::uninitialize() that provides uninitialize-once semantics...

Here is the call graph for this function:

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.

Parameters
[in]commit_epochReturns kRetOk iff the durable global epoch reaches this value.
[in]wait_microsecondsOr, 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().

71  {
72  return pimpl_->wait_for_commit(commit_epoch, wait_microseconds);
73 }
ErrorCode wait_for_commit(Epoch commit_epoch, int64_t wait_microseconds)

Here is the call graph for this function:

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().

35  {
36  pimpl_->wait_for_current_global_epoch(target_epoch, wait_microseconds);
37 }
void wait_for_current_global_epoch(Epoch target_epoch, int64_t wait_microseconds)

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: