mirror of https://gitee.com/bigwinds/arangodb
only sync RocksDB WAL in MMFiles engine when there is a reason to do so (#2863)
This commit is contained in:
parent
d8c349143e
commit
582d3e5fd1
|
@ -478,9 +478,23 @@ int MMFilesTransactionState::writeCommitMarker() {
|
||||||
TRI_IF_FAILURE("TransactionWriteCommitMarkerNoRocksSync") { return TRI_ERROR_NO_ERROR; }
|
TRI_IF_FAILURE("TransactionWriteCommitMarkerNoRocksSync") { return TRI_ERROR_NO_ERROR; }
|
||||||
|
|
||||||
if (_options.waitForSync) {
|
if (_options.waitForSync) {
|
||||||
// also sync RocksDB WAL
|
// 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();
|
MMFilesPersistentIndexFeature::syncWal();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TRI_IF_FAILURE("TransactionWriteCommitMarkerThrow") {
|
TRI_IF_FAILURE("TransactionWriteCommitMarkerThrow") {
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
|
|
|
@ -199,6 +199,16 @@ Result TransactionState::ensureCollections(int nestingLevel) {
|
||||||
return useCollections(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
|
/// @brief use all participating collections of a transaction
|
||||||
Result TransactionState::useCollections(int nestingLevel) {
|
Result TransactionState::useCollections(int nestingLevel) {
|
||||||
Result res;
|
Result res;
|
||||||
|
|
|
@ -123,6 +123,9 @@ class TransactionState {
|
||||||
/// @brief use all participating collections of a transaction
|
/// @brief use all participating collections of a transaction
|
||||||
Result useCollections(int nestingLevel);
|
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
|
/// @brief release collection locks for a transaction
|
||||||
int unuseCollections(int nestingLevel);
|
int unuseCollections(int nestingLevel);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue