20 #include <glog/logging.h>
45 get_global_memory_anchors()->restart_manager_memory_;
49 LOG(INFO) <<
"Initializing RestartManager..";
63 LOG(INFO) <<
"Uninitializing RestartManager..";
74 LOG(INFO) <<
"Recovering the database... durable_epoch=" << durable_epoch
75 <<
", snapshot_epoch=" << snapshot_epoch;
78 if (!snapshot_epoch.is_valid()) {
79 LOG(INFO) <<
"The database is in initial state. Nothing to recover.";
83 LOG(INFO) <<
"Interesting. durable_epoch is initial value, but we have snapshot."
84 <<
" This means epoch wrapped around!";
88 if (durable_epoch == snapshot_epoch) {
89 LOG(INFO) <<
"The snapshot is up-to-date. No need to recover.";
93 LOG(INFO) <<
"There are logs that are durable but not yet snapshotted.";
95 LOG(INFO) <<
"Launching snapshot..";
99 LOG(INFO) <<
"Finished initial snapshot during start-up.";
106 LOG(INFO) <<
"Now we can start processing transaction";
112 LOG(INFO) <<
"Redoing metadata operations from " << snapshot_epoch <<
" to " << durable_epoch;
118 uint64_t oldest_offset;
119 uint64_t durable_offset;
121 ASSERT_ND(oldest_offset % (1 << 12) == 0);
122 ASSERT_ND(durable_offset % (1 << 12) == 0);
123 ASSERT_ND(oldest_offset <= durable_offset);
125 uint32_t read_size = durable_offset - oldest_offset;
127 LOG(INFO) <<
"Will read " << read_size <<
" bytes from meta log";
136 char* buf =
reinterpret_cast<char*
>(buffer.
get_block());
138 uint32_t processed = 0;
140 while (cur < read_size) {
151 if (epoch > durable_epoch) {
152 LOG(FATAL) <<
"WTF. This should have been checked in meta logger's startup??";
154 if (snapshot_epoch.
is_valid() && epoch <= snapshot_epoch) {
173 LOG(ERROR) <<
"Unexpected log type in metadata log:" << entry->
header_;
178 LOG(INFO) <<
"Redone " << processed <<
" metadata operations";
LogCode
A unique identifier of all log types.
numa_alloc_onnode() and numa_free().
void emprace_back(ErrorStack &&error_stack)
If the given ErrorStack is an error, this method adds it to the end of this batch.
SnapshotManagerPimpl * get_pimpl()
Do not use this unless you know what you are doing.
storage::StorageManager * get_storage_manager() const
See Storage Manager.
#define ERROR_STACK(e)
Instantiates ErrorStack with the given foedus::error_code, creating an error stack with the current f...
ErrorStack initialize_once() override
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
ErrorStack handle_snapshot_triggered(Snapshot *new_snapshot)
handle_snapshot() calls this when it should start snapshotting.
bool is_initialized() const override
Returns whether the object has been already initialized or not.
0x0005 : "GENERAL: A dependent module is not initialized yet. This implies a wrong initialization ord...
Brings error stacktrace information as return value of functions.
void alloc(uint64_t size, uint64_t alignment, AllocType alloc_type, int numa_node) noexcept
Allocate a memory, releasing the current memory if exists.
Declares common log types used in all packages.
const EngineOptions & get_options() const
bool is_master() const
Returns if this engine object is a master instance.
savepoint::SavepointManager * get_savepoint_manager() const
See Savepoint Manager.
RestartManagerControlBlock * control_block_
0x1027 : foedus::storage::hash::HashCreateLogType .
Batches zero or more ErrorStack objects to represent in one ErrorStack.
Analogue of boost::filesystem::path.
Declares common log types for all (or at least multiple) storage types.
log::LogManager * get_log_manager() const
See Log Manager.
0x1021 : foedus::storage::array::ArrayCreateLogType .
Epoch get_epoch() const __attribute__((always_inline))
ErrorStack uninitialize_once() override
Represents one snapshot that converts all logs from base epoch to valid_until epoch into snapshot fil...
void * get_block() const
Returns the memory block.
uint64_t file_size(const Path &p)
Returns size of the file.
ErrorStack recover()
Recover the state of database from recent snapshot files and transaction logs.
#define SUMMARIZE_ERROR_BATCH(x)
This macro calls ErrorStackBatch::summarize() with automatically provided parameters.
xct::XctManager * get_xct_manager() const
See Transaction Manager.
std::string construct_meta_log_path() const
metadata log file is placed in node-0/logger-0 folder
Epoch get_durable_global_epoch() const
Returns the durable epoch of the entire engine.
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
Represents an I/O stream on one file without filesystem caching.
Represents one memory block aligned to actual OS/hardware pages.
foedus::fs::DeviceEmulationOptions emulation_
Settings to emulate slower logging device.
const ErrorStack kRetOk
Normal return value for no-error case.
Storage Manager class that provides API to create/open/close/drop key-value stores.
0 is reserved as a non-existing log type.
soc::SocManager * get_soc_manager() const
See SOC and IPC.
void stop_snapshot_thread()
This is a hidden API called at the beginning of engine shutdown (namely restart manager).
0x3001 : foedus::log::FillerLogType .
void get_meta_logger_offsets(uint64_t *oldest_offset, uint64_t *durable_offset) const
Returns the saved information of metadata logger in lateset savepoint.
ErrorStack redo_meta_logs(Epoch durable_epoch, Epoch snapshot_epoch)
Redo metadata operation (create/drop storage) since the latest snapshot.
snapshot::SnapshotManager * get_snapshot_manager() const
See Snapshot Manager.
Pimpl object of SnapshotManager.
As there is no transaction in ep-1, initial durable_epoch is 1.
void drop_storage_apply(StorageId id)
This is called while restart to apply DROP STORAGE logs.
Base type for CREATE STORAGE operation.
ErrorStack reinitialize_for_recovered_snapshot()
Special method called only from recovery manager.
0x0006 : "GENERAL: A dependent module is already uninitialized. This implies a wrong uninitialization...
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Epoch get_snapshot_epoch() const
Returns the most recently snapshot-ed epoch, all logs upto this epoch is safe to delete.
#define WRAP_ERROR_CODE(x)
Same as CHECK_ERROR(x) except it receives only an error code, thus more efficient.
0x1031 : foedus::storage::masstree::MasstreeCreateLogType .
0x1025 : foedus::storage::sequential::SequentialCreateLogType .
The offset is set to offset bytes.
0x1011 : foedus::storage::DropLogType .
EpochInteger value() const
Returns the raw integer representation.
SharedMemoryRepo * get_shared_memory_repo()
Returns the shared memories maintained across SOCs.
0x3002 : foedus::log::EpochMarkerLogType .