1
0
Fork 0

Bug fix/arangosearch lock issue (#6871)

* ensure no concurrent links midifications

* another attempt to fix

* reduce scope of the lock

* Revert "reduce scope of the lock"

This reverts commit 2eed8eb75c372c1723bcd46b05018843edcc51e0.
This commit is contained in:
Andrey Abramov 2018-10-12 20:50:28 +03:00 committed by GitHub
parent 7cdfec2f7e
commit b8dcf51631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -1116,9 +1116,22 @@ arangodb::Result IResearchView::dropImpl() {
}
std::unordered_set<TRI_voc_cid_t> collections;
auto res = IResearchLinkHelper::updateLinks(
collections, vocbase(), *this, emptyObjectSlice(), stale
);
arangodb::Result res;
{
if (!_updateLinksLock.try_lock()) {
return arangodb::Result(
TRI_ERROR_FAILED, // FIXME use specific error code
std::string("failed to remove arangosearch view '") + name()
);
}
ADOPT_SCOPED_LOCK_NAMED(_updateLinksLock, lock);
res = IResearchLinkHelper::updateLinks(
collections, vocbase(), *this, emptyObjectSlice(), stale
);
}
if (!res.ok()) {
return arangodb::Result(
@ -1922,6 +1935,8 @@ arangodb::Result IResearchView::updateProperties(
if (partialUpdate) {
mtx.unlock(); // release lock
SCOPED_LOCK(_updateLinksLock);
return IResearchLinkHelper::updateLinks(
collections, vocbase(), *this, links
);
@ -1931,6 +1946,8 @@ arangodb::Result IResearchView::updateProperties(
mtx.unlock(); // release lock
SCOPED_LOCK(_updateLinksLock);
return IResearchLinkHelper::updateLinks(
collections, vocbase(), *this, links, stale
);

View File

@ -1,4 +1,4 @@
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2017 EMC Corporation
@ -371,6 +371,7 @@ class IResearchView
mutable irs::async_utils::read_write_mutex _mutex; // for use with member maps/sets and '_metaState'
PersistedStore _storePersisted;
std::mutex _readerLock; // prevents query cache double invalidation
std::mutex _updateLinksLock; // prevents simultaneous 'updateLinks'
FlushCallback _flushCallback; // responsible for flush callback unregistration
std::function<void(arangodb::transaction::Methods& trx, arangodb::transaction::Status status)> _trxReadCallback; // for snapshot(...)
std::function<void(arangodb::transaction::Methods& trx, arangodb::transaction::Status status)> _trxWriteCallback; // for insert(...)/remove(...)