本文整理汇总了C++中WT_SESSION::log_flush方法的典型用法代码示例。如果您正苦于以下问题:C++ WT_SESSION::log_flush方法的具体用法?C++ WT_SESSION::log_flush怎么用?C++ WT_SESSION::log_flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_SESSION
的用法示例。
在下文中一共展示了WT_SESSION::log_flush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: waitUntilDurable
void WiredTigerSessionCache::waitUntilDurable(bool forceCheckpoint) {
const int shuttingDown = _shuttingDown.fetchAndAdd(1);
ON_BLOCK_EXIT([this] { _shuttingDown.fetchAndSubtract(1); });
uassert(ErrorCodes::ShutdownInProgress,
"Cannot wait for durability because a shutdown is in progress",
!(shuttingDown & kShuttingDownMask));
// When forcing a checkpoint with journaling enabled, don't synchronize with other
// waiters, as a log flush is much cheaper than a full checkpoint.
if (forceCheckpoint && _engine->isDurable()) {
UniqueWiredTigerSession session = getSession();
WT_SESSION* s = session->getSession();
{
stdx::unique_lock<stdx::mutex> lk(_journalListenerMutex);
JournalListener::Token token = _journalListener->getToken();
invariantWTOK(s->checkpoint(s, NULL));
_journalListener->onDurable(token);
}
LOG(4) << "created checkpoint (forced)";
return;
}
uint32_t start = _lastSyncTime.load();
// Do the remainder in a critical section that ensures only a single thread at a time
// will attempt to synchronize.
stdx::unique_lock<stdx::mutex> lk(_lastSyncMutex);
uint32_t current = _lastSyncTime.loadRelaxed(); // synchronized with writes through mutex
if (current != start) {
// Someone else synced already since we read lastSyncTime, so we're done!
return;
}
_lastSyncTime.store(current + 1);
// Nobody has synched yet, so we have to sync ourselves.
auto session = getSession();
WT_SESSION* s = session->getSession();
// This gets the token (OpTime) from the last write, before flushing (either the journal, or a
// checkpoint), and then reports that token (OpTime) as a durable write.
stdx::unique_lock<stdx::mutex> jlk(_journalListenerMutex);
JournalListener::Token token = _journalListener->getToken();
// Use the journal when available, or a checkpoint otherwise.
if (_engine->isDurable()) {
invariantWTOK(s->log_flush(s, "sync=on"));
LOG(4) << "flushed journal";
} else {
invariantWTOK(s->checkpoint(s, NULL));
LOG(4) << "created checkpoint";
}
_journalListener->onDurable(token);
}