} else {
// Deferred write: enqueue with current writeback counter.
const auto wc = m_ctx->hash_table()->writeback_extent_count();
- m_pending_checkpoints.push_back({ wc, ini_string });
+ const auto seq = m_next_checkpoint_seq++;
+ m_pending_checkpoints.push_back({ wc, seq, Timer(), ini_string });
m_crawl_clean = crawl_saved;
+ BEESLOGINFO("checkpoint queued #" << seq << " age " << static_cast<uint64_t>(m_pending_checkpoints.back().queued.age()) << "s writeback " << wc);
}
}
{
while (true) {
string write_ini;
+ uint64_t write_seq = 0;
+ uint64_t write_wbcount = 0;
+ Timer write_queued;
{
unique_lock<mutex> lock(m_mutex);
if (m_pending_checkpoints.empty()) return;
if (!force && writeback_now - second.writeback_count < extent_count) {
break;
}
+ const auto &dropped = m_pending_checkpoints.front();
+ BEESLOGINFO("checkpoint discarded #" << dropped.seq << " age " << static_cast<uint64_t>(dropped.queued.age()) << "s writeback " << dropped.writeback_count);
m_pending_checkpoints.pop_front();
}
// been enqueued meanwhile, the next coalesce iteration discards
// this one in favour of the newer one. Either way the queue
// holds the obligation until a write succeeds.
- write_ini = front.ini_string;
+ write_ini = front.ini_string;
+ write_seq = front.seq;
+ write_wbcount = front.writeback_count;
+ write_queued = front.queued;
}
m_point_file.write(write_ini); // slow I/O outside the lock; may throw
+ BEESLOGINFO("checkpoint wrote #" << write_seq << " age " << static_cast<uint64_t>(write_queued.age()) << "s writeback " << write_wbcount);
// Write succeeded. Pop the entry we just wrote. The front is still
// that entry because flush_pending_checkpoints is single-consumer
- // (the writeback thread, REPL save-state, and the shutdown flush do
- // not overlap), and snapshot_point() only ever appends to the tail.
+ // (the writeback thread and the shutdown flush do not
+ // overlap), and snapshot_point() only ever appends to the tail.
{
unique_lock<mutex> lock(m_mutex);
m_pending_checkpoints.pop_front();
}
+ BEESLOGINFO("checkpoint dequeued #" << write_seq << " age " << static_cast<uint64_t>(write_queued.age()) << "s writeback " << write_wbcount);
// loop: more entries may now be eligible, or newer ones have arrived
}
}
/// A checkpoint snapshot waiting to be written to disk.
struct PendingCheckpoint {
uint64_t writeback_count; ///< m_hash_table->writeback_extent_count() at snapshot time.
+ uint64_t seq; ///< Sequence number for correlating state-writeback log lines.
+ Timer queued; ///< Started at enqueue; age() is the data's age when written or discarded.
string ini_string; ///< Serialised beespoint.ini content.
};
- deque<PendingCheckpoint> m_pending_checkpoints; ///< Queue of deferred checkpoints.
+ deque<PendingCheckpoint> m_pending_checkpoints; ///< Queue of deferred checkpoints.
+ uint64_t m_next_checkpoint_seq = 0; ///< Next sequence number to assign to a deferred checkpoint.
vector<shared_ptr<BeesScanMode>> m_scanners; ///< Active scan-mode strategy objects.