summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@oath.com>2017-12-11 13:45:10 +0000
committerTor Egge <Tor.Egge@oath.com>2017-12-11 14:49:46 +0000
commitfefc3ca0ce485ac61f8ce67eb08edb2fe23c7137 (patch)
treec30d27642847623f57e24bade6b39235c209c5bd /searchcore
parent74f4f321357c0349614ee68c6073a07f40d82e11 (diff)
Use standard locking in searchcore (pass 1).
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/flushengine/flushengine.cpp10
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/matcher.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/matcher.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp28
-rw-r--r--searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h3
-rw-r--r--searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp10
-rw-r--r--searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h3
11 files changed, 40 insertions, 36 deletions
diff --git a/searchcore/src/tests/proton/flushengine/flushengine.cpp b/searchcore/src/tests/proton/flushengine/flushengine.cpp
index 985a970a380..d1a98f1b7d3 100644
--- a/searchcore/src/tests/proton/flushengine/flushengine.cpp
+++ b/searchcore/src/tests/proton/flushengine/flushengine.cpp
@@ -11,8 +11,8 @@
#include <vespa/searchcore/proton/test/dummy_flush_target.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/data/slime/slime.h>
-#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/test/insertion_operators.h>
+#include <mutex>
#include <chrono>
#include <vespa/log/log.h>
@@ -123,7 +123,7 @@ public:
search::SerialNum _oldestSerial;
search::SerialNum _currentSerial;
uint32_t _pendingDone;
- vespalib::Lock _lock;
+ std::mutex _lock;
vespalib::CountDownLatch _done;
FlushDoneHistory _flushDoneHistory;
@@ -168,7 +168,7 @@ public:
// Called once by flush engine slave thread for each task done
void taskDone()
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
++_pendingDone;
}
@@ -178,7 +178,7 @@ public:
void
flushDone(search::SerialNum oldestSerial) override
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
LOG(info, "SimpleHandler(%s)::flushDone(%" PRIu64 ")",
getName().c_str(), oldestSerial);
_oldestSerial = std::max(_oldestSerial, oldestSerial);
@@ -191,7 +191,7 @@ public:
FlushDoneHistory getFlushDoneHistory()
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _flushDoneHistory;
}
};
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp
index 026cbc00604..6667db02173 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp
@@ -4,6 +4,8 @@
#include <vespa/searchlib/query/queryterm.h>
#include <vespa/searchlib/attribute/attributevector.h>
#include <vespa/searchlib/attribute/singlesmallnumericattribute.h>
+#include <mutex>
+
#include <vespa/log/log.h>
LOG_SETUP(".proton.documentmetastore.lid_allocator");
@@ -223,7 +225,7 @@ class BlackListBlueprint : public SimpleLeafBlueprint
{
private:
AttributeVector::SearchContext::UP _searchCtx;
- vespalib::Lock _lock;
+ mutable std::mutex _lock;
mutable std::vector<search::fef::TermFieldMatchData *> _matchDataVector;
virtual SearchIterator::UP
@@ -235,7 +237,7 @@ private:
search::fef::TermFieldMatchData *tfmd =
new search::fef::TermFieldMatchData;
{
- vespalib::LockGuard lock(_lock);
+ std::lock_guard<std::mutex> lock(_lock);
_matchDataVector.push_back(tfmd);
}
return _searchCtx->createIterator(tfmd, strict);
diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp
index adb14b11c71..05dc75146c7 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.cpp
@@ -59,7 +59,7 @@ AttributeLimiter::toString(DiversityCutoffStrategy strategy)
SearchIterator::UP
AttributeLimiter::create_search(size_t want_hits, size_t max_group_size, bool strictSearch)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
const uint32_t my_field_id = 0;
search::fef::MatchDataLayout layout;
auto my_handle = layout.allocTermField(my_field_id);
diff --git a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h
index 67180da6a10..95f7bf4e42b 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/attribute_limiter.h
@@ -4,11 +4,11 @@
#include <vespa/searchlib/queryeval/searchable.h>
#include <vespa/vespalib/stllike/string.h>
-#include <vespa/vespalib/util/sync.h>
#include <vespa/searchlib/queryeval/searchiterator.h>
#include <vespa/searchlib/queryeval/blueprint.h>
#include <vespa/searchlib/fef/matchdata.h>
+#include <mutex>
namespace proton {
namespace matching {
@@ -43,7 +43,7 @@ private:
vespalib::string _attribute_name;
bool _descending;
vespalib::string _diversity_attribute;
- vespalib::Lock _lock;
+ std::mutex _lock;
std::vector<search::fef::MatchData::UP> _match_datas;
search::queryeval::Blueprint::UP _blueprint;
ssize_t _estimatedHits;
diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp
index 2a3df5aeb52..bbe6f604e4e 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp
@@ -152,7 +152,7 @@ Matcher::Matcher(const search::index::Schema &schema,
MatchingStats
Matcher::getStats()
{
- vespalib::LockGuard guard(_statsLock);
+ std::lock_guard<std::mutex> guard(_statsLock);
MatchingStats stats = std::move(_stats);
_stats = std::move(MatchingStats());
_stats.softDoomFactor(stats.softDoomFactor());
@@ -315,7 +315,7 @@ Matcher::match(const SearchRequest &request,
{
fastos::TimeStamp softLimit = uint64_t((1.0 - _rankSetup->getSoftTimeoutTailCost()) * request.getTimeout());
fastos::TimeStamp duration = request.getTimeUsed();
- vespalib::LockGuard guard(_statsLock);
+ std::lock_guard<std::mutex> guard(_statsLock);
_stats.add(my_stats);
if (my_stats.softDoomed()) {
LOG(info, "Triggered softtimeout limit=%1.3f and duration=%1.3f", softLimit.sec(), duration.sec());
diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.h b/searchcore/src/vespa/searchcore/proton/matching/matcher.h
index 42a74e3c29b..8415f659473 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/matcher.h
+++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.h
@@ -15,8 +15,8 @@
#include <vespa/searchlib/query/base.h>
#include <vespa/vespalib/util/clock.h>
#include <vespa/vespalib/util/closure.h>
-#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/util/thread_bundle.h>
+#include <mutex>
namespace search {
namespace grouping {
@@ -52,7 +52,7 @@ private:
search::fef::BlueprintFactory _blueprintFactory;
search::fef::RankSetup::SP _rankSetup;
ViewResolver _viewResolver;
- vespalib::Lock _statsLock;
+ std::mutex _statsLock;
MatchingStats _stats;
const vespalib::Clock &_clock;
QueryLimiter &_queryLimiter;
diff --git a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp
index b6c6c798506..afaf61cab5d 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp
@@ -3,7 +3,7 @@
#include "sessionmanager.h"
#include <vespa/vespalib/stllike/lrucache_map.hpp>
#include <vespa/vespalib/stllike/hash_map.hpp>
-#include <vespa/vespalib/util/sync.h>
+#include <mutex>
#include <algorithm>
#include <vespa/log/log.h>
@@ -18,7 +18,7 @@ using Stats = SessionManager::Stats;
struct SessionCacheBase {
protected:
Stats _stats;
- vespalib::Lock _lock;
+ mutable std::mutex _lock;
void entryDropped(const SessionId &id);
~SessionCacheBase() {}
@@ -32,7 +32,7 @@ struct SessionCache : SessionCacheBase {
SessionCache(uint32_t max_size) : _cache(max_size) {}
void insert(EntryUP session) {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
const SessionId &id(session->getSessionId());
if (_cache.size() >= _cache.capacity()) {
entryDropped(id);
@@ -41,7 +41,7 @@ struct SessionCache : SessionCacheBase {
_stats.numInsert++;
}
EntryUP pick(const SessionId & id) {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
EntryUP ret;
if (_cache.hasKey(id)) {
_stats.numPick++;
@@ -56,7 +56,7 @@ struct SessionCache : SessionCacheBase {
}
std::vector<EntryUP> stealTimedOutSessions(fastos::TimeStamp currentTime) {
std::vector<EntryUP> toDestruct;
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
toDestruct.reserve(_cache.size());
for (auto it(_cache.begin()), mt(_cache.end()); it != mt;) {
auto &session = *it;
@@ -71,14 +71,14 @@ struct SessionCache : SessionCacheBase {
return toDestruct;
}
Stats getStats() {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
Stats stats = _stats;
stats.numCached = _cache.size();
_stats = Stats();
return stats;
}
bool empty() const {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _cache.empty();
}
};
@@ -89,13 +89,13 @@ struct SessionMap : SessionCacheBase {
vespalib::hash_map<SessionId, EntrySP> _map;
void insert(EntrySP session) {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
const SessionId &id(session->getSessionId());
_map.insert(std::make_pair(id, session));
_stats.numInsert++;
}
EntrySP pick(const SessionId & id) {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
auto it = _map.find(id);
if (it != _map.end()) {
_stats.numPick++;
@@ -110,7 +110,7 @@ struct SessionMap : SessionCacheBase {
std::vector<EntrySP> stealTimedOutSessions(fastos::TimeStamp currentTime) {
std::vector<EntrySP> toDestruct;
std::vector<SessionId> keys;
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
keys.reserve(_map.size());
toDestruct.reserve(_map.size());
for (auto & it : _map) {
@@ -128,23 +128,23 @@ struct SessionMap : SessionCacheBase {
return toDestruct;
}
Stats getStats() {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
Stats stats = _stats;
stats.numCached = _map.size();
_stats = Stats();
return stats;
}
size_t size() const {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _map.size();
}
bool empty() const {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _map.empty();
}
template <typename F>
void each(F f) const {
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
for (const auto &entry: _map) {
f(*entry.second);
}
diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.cpp b/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.cpp
index 12ba5e7ab29..96025f5eaad 100644
--- a/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.cpp
+++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.cpp
@@ -20,7 +20,7 @@ void
TransportLatch::send(ResultUP result, bool documentWasFound)
{
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
if (!_result) {
_result = std::move(result);
} else if (result->hasError()) {
diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h b/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h
index 10dae553a80..d069f7953f3 100644
--- a/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h
+++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h
@@ -4,6 +4,7 @@
#include <vespa/persistence/spi/result.h>
#include <vespa/searchcore/proton/common/feedtoken.h>
#include <vespa/vespalib/util/sequence.h>
+#include <mutex>
namespace proton {
@@ -17,7 +18,7 @@ private:
using UpdateResult = storage::spi::UpdateResult;
using RemoveResult = storage::spi::RemoveResult;
vespalib::CountDownLatch _latch;
- vespalib::Lock _lock;
+ std::mutex _lock;
ResultUP _result;
public:
diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp
index cda1d0103c7..30e9382ae14 100644
--- a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp
+++ b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp
@@ -51,7 +51,7 @@ SummaryEngine::close()
{
LOG(debug, "Closing summary engine");
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
_closed = true;
}
LOG(debug, "Handshaking with task manager");
@@ -61,21 +61,21 @@ SummaryEngine::close()
ISearchHandler::SP
SummaryEngine::putSearchHandler(const DocTypeName &docTypeName, const ISearchHandler::SP & searchHandler)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _handlers.putHandler(docTypeName, searchHandler);
}
ISearchHandler::SP
SummaryEngine::getSearchHandler(const DocTypeName &docTypeName)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _handlers.getHandler(docTypeName);
}
ISearchHandler::SP
SummaryEngine::removeSearchHandler(const DocTypeName &docTypeName)
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
return _handlers.removeHandler(docTypeName);
}
@@ -107,7 +107,7 @@ SummaryEngine::getDocsums(DocsumRequest::UP req)
} else {
vespalib::Sequence<ISearchHandler*>::UP snapshot;
{
- vespalib::LockGuard guard(_lock);
+ std::lock_guard<std::mutex> guard(_lock);
snapshot = _handlers.snapshot();
}
if (snapshot->valid()) {
diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h
index d599f1521ec..2420a656909 100644
--- a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h
+++ b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.h
@@ -6,6 +6,7 @@
#include <vespa/searchlib/engine/docsumapi.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
#include <vespa/searchcore/proton/common/doctypename.h>
+#include <mutex>
namespace proton {
@@ -16,7 +17,7 @@ private:
using DocsumRequest = search::engine::DocsumRequest;
using DocsumClient = search::engine::DocsumClient;
- vespalib::Lock _lock;
+ std::mutex _lock;
bool _closed;
HandlerMap<ISearchHandler> _handlers;
vespalib::ThreadStackExecutor _executor;