diff options
-rw-r--r-- | common/pipeline.cpp | 4 | ||||
-rw-r--r-- | common/storage/entitystore.cpp | 13 | ||||
-rw-r--r-- | common/storage/entitystore.h | 2 |
3 files changed, 13 insertions, 6 deletions
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) | |||
287 | 287 | ||
288 | void Pipeline::cleanupRevisions(qint64 revision) | 288 | void Pipeline::cleanupRevisions(qint64 revision) |
289 | { | 289 | { |
290 | d->entityStore.cleanupRevisions(revision); | 290 | //We have to set revisionChanged, otherwise a call to commit might abort |
291 | //the transaction when not using the implicit internal transaction | ||
292 | d->revisionChanged = d->entityStore.cleanupRevisions(revision); | ||
291 | } | 293 | } |
292 | 294 | ||
293 | 295 | ||
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) | |||
307 | DataStore::setCleanedUpRevision(d->transaction, revision); | 307 | DataStore::setCleanedUpRevision(d->transaction, revision); |
308 | } | 308 | } |
309 | 309 | ||
310 | void EntityStore::cleanupRevisions(qint64 revision) | 310 | bool EntityStore::cleanupRevisions(qint64 revision) |
311 | { | 311 | { |
312 | bool implicitTransaction = false; | 312 | bool implicitTransaction = false; |
313 | if (!d->transaction) { | 313 | if (!d->transaction) { |
@@ -315,13 +315,18 @@ void EntityStore::cleanupRevisions(qint64 revision) | |||
315 | implicitTransaction = true; | 315 | implicitTransaction = true; |
316 | } | 316 | } |
317 | const auto lastCleanRevision = DataStore::cleanedUpRevision(d->transaction); | 317 | const auto lastCleanRevision = DataStore::cleanedUpRevision(d->transaction); |
318 | SinkTrace() << "Cleaning up from " << lastCleanRevision + 1 << " to " << revision; | 318 | const auto firstRevisionToCleanup = lastCleanRevision + 1; |
319 | for (qint64 rev = lastCleanRevision + 1; rev <= revision; rev++) { | 319 | bool cleanupIsNecessary = firstRevisionToCleanup <= revision; |
320 | cleanupRevision(revision); | 320 | if (cleanupIsNecessary) { |
321 | SinkTrace() << "Cleaning up from " << firstRevisionToCleanup << " to " << revision; | ||
322 | for (qint64 rev = firstRevisionToCleanup; rev <= revision; rev++) { | ||
323 | cleanupRevision(revision); | ||
324 | } | ||
321 | } | 325 | } |
322 | if (implicitTransaction) { | 326 | if (implicitTransaction) { |
323 | commitTransaction(); | 327 | commitTransaction(); |
324 | } | 328 | } |
329 | return cleanupIsNecessary; | ||
325 | } | 330 | } |
326 | 331 | ||
327 | QVector<QByteArray> EntityStore::fullScan(const QByteArray &type) | 332 | 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: | |||
47 | bool modify(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &, const QByteArrayList &deletions, bool replayToSource, const PreprocessModification &); | 47 | bool modify(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &, const QByteArrayList &deletions, bool replayToSource, const PreprocessModification &); |
48 | bool remove(const QByteArray &type, const QByteArray &uid, bool replayToSource, const PreprocessRemoval &); | 48 | bool remove(const QByteArray &type, const QByteArray &uid, bool replayToSource, const PreprocessRemoval &); |
49 | void cleanupRevision(qint64 revision); | 49 | void cleanupRevision(qint64 revision); |
50 | void cleanupRevisions(qint64 revision); | 50 | bool cleanupRevisions(qint64 revision); |
51 | 51 | ||
52 | void startTransaction(Sink::Storage::DataStore::AccessMode); | 52 | void startTransaction(Sink::Storage::DataStore::AccessMode); |
53 | void commitTransaction(); | 53 | void commitTransaction(); |