Commit dfa0e118 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

CollectionScheduler: resolve cache policy before locking mutex

We don't need the lock to do that and it prevents a possible deadlock when
T1 holds the lock and tries to run an SQL query to resolve collection cache
policy, while another lock is holding the SQL lock and is waiting for the
CollectionScheduler lock to be released.
parent 82e2af04
......@@ -235,14 +235,14 @@ void CollectionScheduler::startScheduler()
// Called in secondary thread
void CollectionScheduler::scheduleCollection(Collection collection, bool shouldStartScheduler)
{
DataStore::self()->activeCachePolicy(collection);
QMutexLocker locker(&mScheduleLock);
auto i = find(collection.id());
if (i != mSchedule.end()) {
mSchedule.erase(i);
}
DataStore::self()->activeCachePolicy(collection);
if (!shouldScheduleCollection(collection)) {
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment