1
0
Fork 0

only sync RocksDB WAL in MMFiles engine when there is a reason to do so (#2863)

This commit is contained in:
Jan 2017-07-26 21:49:41 +02:00 committed by Frank Celler
parent d8c349143e
commit 582d3e5fd1
3 changed files with 29 additions and 2 deletions

View File

@ -478,8 +478,22 @@ int MMFilesTransactionState::writeCommitMarker() {
TRI_IF_FAILURE("TransactionWriteCommitMarkerNoRocksSync") { return TRI_ERROR_NO_ERROR; }
if (_options.waitForSync) {
// also sync RocksDB WAL
MMFilesPersistentIndexFeature::syncWal();
// also sync RocksDB WAL if required
bool hasPersistentIndex = false;
allCollections([&hasPersistentIndex](TransactionCollection* collection) {
auto c = static_cast<MMFilesTransactionCollection*>(collection);
if (c->canAccess(AccessMode::Type::WRITE) &&
c->collection()->getPhysical()->hasIndexOfType(arangodb::Index::TRI_IDX_TYPE_PERSISTENT_INDEX)) {
hasPersistentIndex = true;
// abort iteration
return false;
}
return true;
});
if (hasPersistentIndex) {
MMFilesPersistentIndexFeature::syncWal();
}
}
TRI_IF_FAILURE("TransactionWriteCommitMarkerThrow") {

View File

@ -198,6 +198,16 @@ int TransactionState::addCollection(TRI_voc_cid_t cid,
Result TransactionState::ensureCollections(int nestingLevel) {
return useCollections(nestingLevel);
}
/// @brief run a callback on all collections
void TransactionState::allCollections(std::function<bool(TransactionCollection*)> const& cb) {
for (auto& trxCollection : _collections) {
if (!cb(trxCollection)) {
// abort early
return;
}
}
}
/// @brief use all participating collections of a transaction
Result TransactionState::useCollections(int nestingLevel) {

View File

@ -123,6 +123,9 @@ class TransactionState {
/// @brief use all participating collections of a transaction
Result useCollections(int nestingLevel);
/// @brief run a callback on all collections
void allCollections(std::function<bool(TransactionCollection*)> const& cb);
/// @brief release collection locks for a transaction
int unuseCollections(int nestingLevel);