mirror of https://gitee.com/bigwinds/arangodb
reduce timeout for write-lock (#8034)
This commit is contained in:
parent
33220fb589
commit
b1dc8fb804
|
@ -154,22 +154,20 @@ std::tuple<Result, TRI_voc_cid_t, uint64_t> RocksDBReplicationContext::bindColle
|
||||||
bool isNumberDocsExclusive = false;
|
bool isNumberDocsExclusive = false;
|
||||||
auto* rcoll = static_cast<RocksDBCollection*>(logical->getPhysical());
|
auto* rcoll = static_cast<RocksDBCollection*>(logical->getPhysical());
|
||||||
if (_snapshot == nullptr) {
|
if (_snapshot == nullptr) {
|
||||||
|
// only DBServers require a corrected document count
|
||||||
|
const double to = ServerState::instance()->isDBServer() ? 10.0 : 1.0;
|
||||||
|
auto lockGuard = scopeGuard([rcoll] { rcoll->unlockWrite(); });
|
||||||
|
if (rcoll->lockWrite(to) == TRI_ERROR_NO_ERROR) {
|
||||||
// fetch number docs and snapshot under exclusive lock
|
// fetch number docs and snapshot under exclusive lock
|
||||||
// this should enable us to correct the count later
|
// this should enable us to correct the count later
|
||||||
auto lockGuard = scopeGuard([rcoll] { rcoll->unlockWrite(); });
|
|
||||||
int res = rcoll->lockWrite(transaction::Options::defaultLockTimeout);
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
|
||||||
lockGuard.cancel();
|
|
||||||
return std::make_tuple(res, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
numberDocuments = rcoll->numberDocuments();
|
|
||||||
isNumberDocsExclusive = true;
|
isNumberDocsExclusive = true;
|
||||||
|
} else {
|
||||||
|
lockGuard.cancel();
|
||||||
|
}
|
||||||
|
numberDocuments = rcoll->numberDocuments();
|
||||||
lazyCreateSnapshot();
|
lazyCreateSnapshot();
|
||||||
lockGuard.fire(); // release exclusive lock
|
|
||||||
} else { // fetch non-exclusive
|
} else { // fetch non-exclusive
|
||||||
numberDocuments = rcoll->numberDocuments();
|
numberDocuments = rcoll->numberDocuments();
|
||||||
lazyCreateSnapshot();
|
|
||||||
}
|
}
|
||||||
TRI_ASSERT(_snapshot != nullptr);
|
TRI_ASSERT(_snapshot != nullptr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue