[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [sink/develop] common: Deal with not using the implicit internal transaction.
From: Christian Mollekopf <chrigi_1 () fastmail ! fm>
Date: 2016-12-02 10:08:34
Message-ID: E1cCkle-0004b8-EP () code ! kde ! org
[Download RAW message or body]
Git commit 64d7d7bdd1edb2bcc305ca007784d0708cf7ef3c by Christian Mollekopf.
Committed on 24/11/2016 at 08:57.
Pushed by cmollekopf into branch 'develop'.
Deal with not using the implicit internal transaction.
M +3 -1 common/pipeline.cpp
M +9 -4 common/storage/entitystore.cpp
M +1 -1 common/storage/entitystore.h
https://commits.kde.org/sink/64d7d7bdd1edb2bcc305ca007784d0708cf7ef3c
diff --git a/common/pipeline.cpp b/common/pipeline.cpp
index d3668bc..1eea631 100644
--- a/common/pipeline.cpp
+++ b/common/pipeline.cpp
@@ -287,7 +287,9 @@ KAsync::Job<qint64> Pipeline::deletedEntity(void const *command, \
size_t size)
void Pipeline::cleanupRevisions(qint64 revision)
{
- d->entityStore.cleanupRevisions(revision);
+ //We have to set revisionChanged, otherwise a call to commit might abort
+ //the transaction when not using the implicit internal transaction
+ d->revisionChanged = d->entityStore.cleanupRevisions(revision);
}
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp
index 79314ad..f6b8f43 100644
--- a/common/storage/entitystore.cpp
+++ b/common/storage/entitystore.cpp
@@ -307,7 +307,7 @@ void EntityStore::cleanupRevision(qint64 revision)
DataStore::setCleanedUpRevision(d->transaction, revision);
}
-void EntityStore::cleanupRevisions(qint64 revision)
+bool EntityStore::cleanupRevisions(qint64 revision)
{
bool implicitTransaction = false;
if (!d->transaction) {
@@ -315,13 +315,18 @@ void EntityStore::cleanupRevisions(qint64 revision)
implicitTransaction = true;
}
const auto lastCleanRevision = DataStore::cleanedUpRevision(d->transaction);
- SinkTrace() << "Cleaning up from " << lastCleanRevision + 1 << " to " << \
revision;
- for (qint64 rev = lastCleanRevision + 1; rev <= revision; rev++) {
- cleanupRevision(revision);
+ const auto firstRevisionToCleanup = lastCleanRevision + 1;
+ bool cleanupIsNecessary = firstRevisionToCleanup <= revision;
+ if (cleanupIsNecessary) {
+ SinkTrace() << "Cleaning up from " << firstRevisionToCleanup << " to " << \
revision; + for (qint64 rev = firstRevisionToCleanup; rev <= revision; rev++) \
{ + cleanupRevision(revision);
+ }
}
if (implicitTransaction) {
commitTransaction();
}
+ return cleanupIsNecessary;
}
QVector<QByteArray> EntityStore::fullScan(const QByteArray &type)
diff --git a/common/storage/entitystore.h b/common/storage/entitystore.h
index be3817b..06ca8c4 100644
--- a/common/storage/entitystore.h
+++ b/common/storage/entitystore.h
@@ -47,7 +47,7 @@ public:
bool modify(const QByteArray &type, const \
ApplicationDomain::ApplicationDomainType &, const QByteArrayList &deletions, bool \
replayToSource, const PreprocessModification &);
bool remove(const QByteArray &type, const QByteArray &uid, bool replayToSource, \
const PreprocessRemoval &); void cleanupRevision(qint64 revision);
- void cleanupRevisions(qint64 revision);
+ bool cleanupRevisions(qint64 revision);
void startTransaction(Sink::Storage::DataStore::AccessMode);
void commitTransaction();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic