diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-30 23:15:23 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-30 23:15:23 +0200 |
commit | 8588cd99ee9f3ba92a7167be3752fe511200131b (patch) | |
tree | 5ecad52cc4a49ebe31d5d410a1eb396e74ca3f9e /common/queryrunner.cpp | |
parent | fe1940830d7cc2e9c652ec9a13ca7f3790ff4079 (diff) | |
download | sink-8588cd99ee9f3ba92a7167be3752fe511200131b.tar.gz sink-8588cd99ee9f3ba92a7167be3752fe511200131b.zip |
Detect and recover from invalid database environment.
Sometimes wrong databases are returned for the name, probably related
to threading/incorrect usage of lmdb.
For the time being we recover from that by detecting it and retrying.
Diffstat (limited to 'common/queryrunner.cpp')
-rw-r--r-- | common/queryrunner.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index ea17176..fd966a9 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp | |||
@@ -408,9 +408,19 @@ QPair<qint64, qint64> QueryWorker<DomainType>::load(const Sink::Query &query, co | |||
408 | QTime time; | 408 | QTime time; |
409 | time.start(); | 409 | time.start(); |
410 | 410 | ||
411 | Sink::Storage storage(Sink::storageLocation(), mResourceInstanceIdentifier); | 411 | Sink::Storage::Transaction transaction; |
412 | storage.setDefaultErrorHandler([](const Sink::Storage::Error &error) { Warning() << "Error during query: " << error.store << error.message; }); | 412 | { |
413 | auto transaction = storage.createTransaction(Sink::Storage::ReadOnly); | 413 | Sink::Storage storage(Sink::storageLocation(), mResourceInstanceIdentifier); |
414 | storage.setDefaultErrorHandler([](const Sink::Storage::Error &error) { Warning() << "Error during query: " << error.store << error.message; }); | ||
415 | transaction = storage.createTransaction(Sink::Storage::ReadOnly); | ||
416 | } | ||
417 | |||
418 | //FIXME this is a temporary measure to recover from a failure to open the named databases correctly. | ||
419 | //Once the actual problem is fixed it will be enough to simply crash if we open the wrong database (which we check in openDatabase already). | ||
420 | while (!transaction.validateNamedDatabases()) { | ||
421 | Sink::Storage storage(Sink::storageLocation(), mResourceInstanceIdentifier); | ||
422 | transaction = storage.createTransaction(Sink::Storage::ReadOnly); | ||
423 | } | ||
414 | auto db = Storage::mainDatabase(transaction, mBufferType); | 424 | auto db = Storage::mainDatabase(transaction, mBufferType); |
415 | 425 | ||
416 | QSet<QByteArray> remainingFilters; | 426 | QSet<QByteArray> remainingFilters; |