summaryrefslogtreecommitdiffstats
path: root/common/queryrunner.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-02-15 10:19:08 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-02-15 11:08:52 +0100
commit531972042d4b610258c8af8a17ec3a99cd063dda (patch)
treeef4356ec141f0f1ccd756e8610b08553b866bf78 /common/queryrunner.h
parentf51963f057bcbdd175114433913a1c5f0eebd546 (diff)
downloadsink-531972042d4b610258c8af8a17ec3a99cd063dda.tar.gz
sink-531972042d4b610258c8af8a17ec3a99cd063dda.zip
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.
Diffstat (limited to 'common/queryrunner.h')
-rw-r--r--common/queryrunner.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/queryrunner.h b/common/queryrunner.h
index a567b3c..af54619 100644
--- a/common/queryrunner.h
+++ b/common/queryrunner.h
@@ -92,6 +92,9 @@ public:
92 typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr emitter(); 92 typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr emitter();
93 93
94private: 94private:
95 void fetch(const Sink::Query &query, const QByteArray &bufferType);
96 KAsync::Job<void> incrementalFetch(const Sink::Query &query, const QByteArray &bufferType);
97
95 Sink::ResourceContext mResourceContext; 98 Sink::ResourceContext mResourceContext;
96 QSharedPointer<Sink::ResourceAccessInterface> mResourceAccess; 99 QSharedPointer<Sink::ResourceAccessInterface> mResourceAccess;
97 QSharedPointer<Sink::ResultProvider<typename DomainType::Ptr>> mResultProvider; 100 QSharedPointer<Sink::ResultProvider<typename DomainType::Ptr>> mResultProvider;
@@ -102,4 +105,5 @@ private:
102 Sink::Log::Context mLogCtx; 105 Sink::Log::Context mLogCtx;
103 bool mInitialQueryComplete = false; 106 bool mInitialQueryComplete = false;
104 bool mQueryInProgress = false; 107 bool mQueryInProgress = false;
108 bool mRequestFetchMore = false;
105}; 109};