libfoedus-core
FOEDUS Core Library
|
A log-gleaner, which constructs a new set of snapshot files during snapshotting. More...
A log-gleaner, which constructs a new set of snapshot files during snapshotting.
LogGleaner is the main class that manages most mechanisms to construct a new set of snapshot files. Snapshot procedure constructs and calls this object during snapshot. It receives partitioning policy (which snapshot partitions to send ranges of keys) per storage and beginning/ending epoch of logs to glean while log-gleaning.
Log-gleaning consists of two components; mapper (foedus::snapshot::LogMapper) and reducer (foedus::snapshot::LogReducer), obviously named after the well-known map-reduce concepts.
LogGleaner launches a set of mapper threads (foedus::snapshot::LogMapper) to read log files. Each LogMapper corresponds to foedus::log::Logger, the NUMA-local log writer which simply writes out log entries produced by local worker threads. Thus, the log files contain log entries that might be sent to any partitions. LogMapper maps each log entry to some partition and send it to a reducer corresponding to the partition. For more details, see foedus::snapshot::LogMapper.
LogGleaner also launches a set of reducer threads (foedus::snapshot::LogReducer), one for each NUMA node. LogReducer sorts log entries sent from LogMapper. The log entries are sorted by key and ordinal (*), then processed just like usual APPLY at the end of transaction, but on top of snapshot files.
(*) otherwise correct result is not guaranteed. For example, imagine the following case:
Ordinal-1 must be processed before ordinal 2.
LogGleaner coordinates the synchronization between mappers and reducers during snapshotting. At the beginning of snapshotting, gleaner wakes up reducers and mappers. Mappers go in to sleep when they process all logs. When all mappers went to sleep, reducers start to also go into sleep when they process all logs they receive. When all of them are done, gleaner initiates the last wrap-up phase. Additionally, LogGleaner is in charge of receiving termination request from the engine if the user invokes Engine::uninitialize() and requesting reducers/mappers to stop.
Reducers/mappers occasionally check if they are requested to stop when they get idle or complete all work. They do the check at least once for a while so that the latency to stop can not be catastrophic.
After all mappers and reducers complete, the last phase of log gleaning is to construct root pages for the storages modified in this snapshotting. Gleaner collects root-page-info from each reducer and combines them to create the root page(s). When all set, gleaner produces maps from storage ID to a new root page ID. This will be written out in a snapshot metadata file by snapshot manager.
Definition at line 104 of file log_gleaner_impl.hpp.
#include <log_gleaner_impl.hpp>
Public Member Functions | |
LogGleaner (Engine *engine, LogGleanerResource *gleaner_resource, const Snapshot &new_snapshot) | |
LogGleaner ()=delete | |
LogGleaner (const LogGleaner &other)=delete | |
LogGleaner & | operator= (const LogGleaner &other)=delete |
ErrorStack | execute () |
Main routine of log gleaner. More... | |
std::string | to_string () const |
const std::map< storage::StorageId, storage::SnapshotPagePointer > & | get_new_root_page_pointers () const |
Returns pointers to new root pages constructed at the end of gleaning. More... | |
![]() | |
LogGleanerRef () | |
LogGleanerRef (Engine *engine) | |
bool | is_error () const |
void | wakeup () |
const Snapshot & | get_cur_snapshot () const |
SnapshotId | get_snapshot_id () const |
Epoch | get_base_epoch () const |
Epoch | get_valid_until_epoch () const |
uint16_t | increment_completed_count () |
uint16_t | increment_completed_mapper_count () |
uint16_t | increment_error_count () |
uint16_t | increment_exit_count () |
bool | is_all_exitted () const |
bool | is_all_completed () const |
bool | is_all_mappers_completed () const |
uint16_t | get_mappers_count () const |
uint16_t | get_reducers_count () const |
uint16_t | get_all_count () const |
![]() | |
Attachable () | |
Attachable (Engine *engine) | |
Attachable (Engine *engine, LogGleanerControlBlock *control_block) | |
Attachable (LogGleanerControlBlock *control_block) | |
Attachable (const Attachable &other) | |
virtual | ~Attachable () |
Attachable & | operator= (const Attachable &other) |
virtual void | attach (LogGleanerControlBlock *control_block) |
Attaches to the given shared memory. More... | |
bool | is_attached () const |
Returns whether the object has been already attached to some shared memory. More... | |
LogGleanerControlBlock * | get_control_block () const |
Engine * | get_engine () const |
void | set_engine (Engine *engine) |
Friends | |
std::ostream & | operator<< (std::ostream &o, const LogGleaner &v) |
Additional Inherited Members | |
![]() | |
storage::PartitionerMetadata * | partitioner_metadata_ |
void * | partitioner_data_ |
![]() | |
Engine * | engine_ |
Most attachable object stores an engine pointer (local engine), so we define it here. More... | |
LogGleanerControlBlock * | control_block_ |
The shared data on shared memory that has been initialized in some SOC or master engine. More... | |
foedus::snapshot::LogGleaner::LogGleaner | ( | Engine * | engine, |
LogGleanerResource * | gleaner_resource, | ||
const Snapshot & | new_snapshot | ||
) |
Definition at line 52 of file log_gleaner_impl.cpp.
|
delete |
|
delete |
ErrorStack foedus::snapshot::LogGleaner::execute | ( | ) |
Main routine of log gleaner.
Definition at line 148 of file log_gleaner_impl.cpp.
References ASSERT_ND, CHECK_ERROR, foedus::Attachable< LogGleanerControlBlock >::control_block_, foedus::debugging::StopWatch::elapsed_sec(), foedus::Attachable< LogGleanerControlBlock >::engine_, foedus::soc::SharedMemoryRepo::get_global_memory_anchors(), foedus::soc::SocManager::get_shared_memory_repo(), foedus::snapshot::LogGleanerRef::get_snapshot_id(), foedus::Engine::get_soc_manager(), foedus::snapshot::LogGleanerRef::is_all_completed(), foedus::snapshot::LogGleanerRef::is_all_exitted(), foedus::snapshot::LogGleanerRef::is_error(), foedus::kRetOk, SPINLOCK_WHILE, and foedus::debugging::StopWatch::stop().
Referenced by foedus::snapshot::SnapshotManagerPimpl::glean_logs().
|
inline |
Returns pointers to new root pages constructed at the end of gleaning.
Definition at line 119 of file log_gleaner_impl.hpp.
Referenced by foedus::snapshot::SnapshotManagerPimpl::glean_logs().
|
delete |
std::string foedus::snapshot::LogGleaner::to_string | ( | ) | const |
Definition at line 307 of file log_gleaner_impl.cpp.
|
friend |
Definition at line 312 of file log_gleaner_impl.cpp.