Skip to content

Commit

Permalink
MB-39292: Allow a forced collection update to reset the manifest uid
Browse files Browse the repository at this point in the history
The following cases of update are currently invalid and will be enabled
by force in this commit.

* Update where the manifest UID goes backwards
* Update where the manifest UID is equal
* Update where the manifest UID goes forwards, but makes no change

With this commit when a manifest is pushed to KV with force=true
any detectable changes will be applied. Detectable changes currently
only means when scope/collections are added or dropped.

In the case of a UID change, but no changes to collections this propagates
to VB::Manifest as a UID only change.

Change-Id: I1962ffe04f1fe6b46aab80b54410247444cc8483
Reviewed-on: http://review.couchbase.org/c/kv_engine/+/140557
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
  • Loading branch information
jimwwalker authored and daverigby committed Dec 8, 2020
1 parent ae14e44 commit b435cf3
Show file tree
Hide file tree
Showing 9 changed files with 302 additions and 106 deletions.
5 changes: 3 additions & 2 deletions engines/ep/src/collections/manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ bool Collections::Manager::warmupLoadManifest(const std::string& dbpath) {
if (rv.has_value()) {
EP_LOG_INFO(
"Collections::Manager::warmupLoadManifest: starting at "
"uid:{:#x}",
rv.value().getUid());
"uid:{:#x} force:{}",
rv.value().getUid(),
rv.value().isForcedUpdate());
*currentManifest.wlock() = std::move(rv.value());
return true;
}
Expand Down
19 changes: 19 additions & 0 deletions engines/ep/src/collections/manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,25 @@ Manifest::Manifest(std::string_view json)
}
}

Manifest::Manifest(Manifest&& other) {
*this = std::move(other);
}

Manifest& Manifest::operator=(Manifest&& other) {
if (*this != other) {
defaultCollectionExists = other.defaultCollectionExists;
scopes = std::move(other.scopes);
collections = std::move(other.collections);
if (other.force) {
uid.reset(other.uid);
} else {
uid = other.uid;
}
force = other.force;
}
return *this;
}

void Manifest::buildCollectionIdToEntryMap() {
for (auto& scope : this->scopes) {
for (auto& collection : scope.second.collections) {
Expand Down
6 changes: 6 additions & 0 deletions engines/ep/src/collections/manifest.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ class Manifest {
struct FlatBuffers {};
explicit Manifest(std::string_view flatbufferData, FlatBuffers tag);

Manifest(Manifest&&);
/**
* Assignment operator that is aware of a forced assign (so uid can go back)
*/
Manifest& operator=(Manifest&& other);

bool doesDefaultCollectionExist() const {
return defaultCollectionExists;
}
Expand Down
Loading

0 comments on commit b435cf3

Please sign in to comment.