diff options
author | Rémi Nicole <nicole@kolabsystems.com> | 2018-08-22 14:16:59 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-08-22 14:28:51 +0200 |
commit | 46313049ac01a3007ef60bdc937442945355a38d (patch) | |
tree | 56ce0cd679367a60ba3a706ac4d207bc9cc82230 /common/changereplay.cpp | |
parent | af91a18748b91f4a4fc0d83247561371d376bec5 (diff) | |
download | sink-46313049ac01a3007ef60bdc937442945355a38d.tar.gz sink-46313049ac01a3007ef60bdc937442945355a38d.zip |
Separate UIDs and Revisions in main databases
Summary:
- Change revision type from `qint64` to `size_t` for LMDB in a couple of places (LMDB supports `unsigned int` or `size_t` which are `long unsigned int` on my machine)
- Better support for database flags (duplicate, integer keys, integer values for now but is extensible)
- Main databases' keys are now revisions
- Some databases switched to integer keys databases:
- Main databases
- the revision to uid mapping database
- the revision to entity type mapping database
- Refactor the entity type's `typeDatabases` method (if in the future we need to change the main databases' flags again)
- New uid to revision mapping database (`uidsToRevisions`):
- Stores all revisions (not uid to latest revision) because we need it for cleaning old revisions
- Flags are: duplicates + integer values (so findLatest finds the latest revision for the given uid)
~~Problems to fix before merging:~~
All Fixed!
- ~~Sometimes Sink can't read what has just been written to the database (maybe because of transactions race conditions)~~
- ~~Most of the times, this results in Sink not able to find the uid for a given revision by reading the `revisions` database~~
- ~~`pipelinetest`'s `testModifyWithConflict` fails because the local changes are overridden~~
~~The first problem prevents me from running benchmarks~~
Reviewers: cmollekopf
Tags: #sink
Differential Revision: https://phabricator.kde.org/D14974
Diffstat (limited to 'common/changereplay.cpp')
-rw-r--r-- | common/changereplay.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/common/changereplay.cpp b/common/changereplay.cpp index d7f46dc..96162b8 100644 --- a/common/changereplay.cpp +++ b/common/changereplay.cpp | |||
@@ -116,16 +116,15 @@ KAsync::Job<void> ChangeReplay::replayNextRevision() | |||
116 | } else { | 116 | } else { |
117 | // TODO: should not use internal representations | 117 | // TODO: should not use internal representations |
118 | const auto key = Storage::Key(Storage::Identifier::fromDisplayByteArray(uid), revision); | 118 | const auto key = Storage::Key(Storage::Identifier::fromDisplayByteArray(uid), revision); |
119 | const auto internalKey = key.toInternalByteArray(); | ||
120 | const auto displayKey = key.toDisplayByteArray(); | 119 | const auto displayKey = key.toDisplayByteArray(); |
121 | QByteArray entityBuffer; | 120 | QByteArray entityBuffer; |
122 | DataStore::mainDatabase(mMainStoreTransaction, type) | 121 | DataStore::mainDatabase(mMainStoreTransaction, type) |
123 | .scan(internalKey, | 122 | .scan(revision, |
124 | [&entityBuffer](const QByteArray &key, const QByteArray &value) -> bool { | 123 | [&entityBuffer](const size_t, const QByteArray &value) -> bool { |
125 | entityBuffer = value; | 124 | entityBuffer = value; |
126 | return false; | 125 | return false; |
127 | }, | 126 | }, |
128 | [this, key](const DataStore::Error &) { SinkErrorCtx(mLogCtx) << "Failed to read the entity buffer " << key; }); | 127 | [this, key](const DataStore::Error &e) { SinkErrorCtx(mLogCtx) << "Failed to read the entity buffer " << key << "error:" << e; }); |
129 | 128 | ||
130 | if (entityBuffer.isEmpty()) { | 129 | if (entityBuffer.isEmpty()) { |
131 | SinkErrorCtx(mLogCtx) << "Failed to replay change " << key; | 130 | SinkErrorCtx(mLogCtx) << "Failed to replay change " << key; |