From 531972042d4b610258c8af8a17ec3a99cd063dda Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 15 Feb 2018 10:19:08 +0100 Subject: Fixed crashes due to concurrently running queries. A single QueryRunner should never have multiple workers running at the same time. We did not properly enforce this in case of incremental updates coming in. The only way I managed to reproduce the crash: * Open a large folder with lots of unread mail in kube * Select a mail in the maillist and hold the down button * This will: * Repeatedly call fetch more * Trigger lot's of mark as read modifications that result in notifications. * Eventually it crashes somewhere in EntityStore, likely because of concurrent access of the filter structure which is shared through the state. We now ensure in the single threaded portion of the code that we only ever run one worker at a time. If we did receive an update during, we remember that change and fetch more once we're done. To be able to call fetch again that portion was also factored out into a separate function. --- common/storage/entitystore.cpp | 1 + common/storage/entitystore.h | 1 + 2 files changed, 2 insertions(+) (limited to 'common/storage') diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 8fbc2ad..020f3fd 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp @@ -459,6 +459,7 @@ void EntityStore::indexLookup(const QByteArray &type, const QByteArray &property void EntityStore::readLatest(const QByteArray &type, const QByteArray &uid, const std::function callback) { + Q_ASSERT(d); auto db = DataStore::mainDatabase(d->getTransaction(), type); db.findLatest(uid, [=](const QByteArray &key, const QByteArray &value) { diff --git a/common/storage/entitystore.h b/common/storage/entitystore.h index 00241f2..3eb0b7b 100644 --- a/common/storage/entitystore.h +++ b/common/storage/entitystore.h @@ -37,6 +37,7 @@ class SINK_EXPORT EntityStore public: typedef QSharedPointer Ptr; EntityStore(const ResourceContext &resourceContext, const Sink::Log::Context &); + ~EntityStore() = default; //Only the pipeline may call the following functions outside of tests bool add(const QByteArray &type, ApplicationDomain::ApplicationDomainType newEntity, bool replayToSource); -- cgit v1.2.3