8000 Bug fix 3.4/fix all numeric guids on restore (#11961) · arangodb/arangodb@0f8cd7d · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f8cd7d

Browse files
authored
Bug fix 3.4/fix all numeric guids on restore (#11961)
* remove invalid GUID values when restoring collections from a dump this fix allows restoring collections from v3.3.0 with their all-numeric GUID values, and silently creates a new, valid GUID for them. v3.3.0 had a bug because it created all-numeric GUID values, which can be confused with numeric collection ids in lookups. v3.3.1 changed the GUID routine to produce something non-numeric already, but collections created with v3.3.0 can have an ambiguous GUID. this patch adjusts the restore routine to drop such GUIDs, so it only changes something if the collections are dumped, dropped on the server and then restored with the flawed GUIDs. * updated CHANGELOG
1 parent 65ff6d5 commit 0f8cd7d

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
v3.4.11 (XXXX-XX-XX)
22
--------------------
33

4+
* Allows restoring collections from v3.3.0 with their all-numeric collection
5+
GUID values, by creating a new, unambiguous collection GUID for them.
6+
v3.3.0 had a bug because it created all-numeric GUID values, which can be
7+
confused with numeric collection ids in lookups. v3.3.1 already changed the
8+
GUID routine to produce something non-numeric already, but collections
9+
created with v3.3.0 can still have an ambiguous GUID. This fix adjusts
10+
the restore routine to drop such GUID values, so it only changes something
11+
if v3.3.0 collections are dumped, dropped on the server and then restored
12+
with the flawed GUIDs.
13+
414
* Fixed velocypack validator for proper check of keys.
515

616
* Fixed issue ES-598. Web UI now shows correct permissions in case wildcard

arangod/RestHandler/RestReplicationHandler.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "Aql/Query.h"
2727
#include "Aql/QueryRegistry.h"
2828
#include "Basics/ConditionLocker.h"
29+
#include "Basics/NumberUtils.h"
2930
#include "Basics/ReadLocker.h"
3031
#include "Basics/Result.h"
3132
#include "Basics/RocksDBUtils.h"
@@ -958,7 +959,6 @@ void RestReplicationHandler::handleCommandRestoreCollection() {
958959

959960
bool overwrite = _request->parsedValue<bool>("overwrite", false);
960961
bool force = _request->parsedValue<bool>("force", false);
961-
;
962962
bool ignoreDistributeShardsLikeErrors =
963963
_request->parsedValue<bool>("ignoreDistributeShardsLikeErrors", false);
964964
uint64_t numberOfShards = _request->parsedValue<uint64_t>("numberOfShards", 0);
@@ -1279,6 +1279,19 @@ Result RestReplicationHandler::processRestoreCollectionCoordinator(
12791279
TRI_ASSERT(numberOfShards > 0);
12801280
toMerge.add(StaticStrings::NumberOfShards, VPackValue(numberOfShards));
12811281
}
1282+
1283+
if (parameters.get(StaticStrings::DataSourceGuid).isString()) {
1284+
std::string const uuid = parameters.get(StaticStrings::DataSourceGuid).copyString();
1285+
bool valid = false;
1286+
NumberUtils::atoi_positive<uint64_t>(uuid.data(), uuid.data() + uuid.size(), valid);
1287+
if (valid) {
1288+
// globallyUniqueId is only numeric. This causes ambiguities later
1289+
// and can only happen for collections created with v3.3.0 (the GUID
1290+
// generation process was changed in v3.3.1 already to fix this issue).
1291+
// remove the globallyUniqueId so a new one will be generated server.side
1292+
toMerge.add(StaticStrings::DataSourceGuid, VPackSlice::nullSlice());
1293+
}
1294+
}
12821295

12831296
// Replication Factor. Will be overwritten if not existent
12841297
VPackSlice const replFactorSlice = parameters.get(StaticStrings::ReplicationFactor);
@@ -2856,11 +2869,22 @@ int RestReplicationHandler::createCollection(VPackSlice slice,
28562869
// because the collection is effectively NEW
28572870
VPackBuilder patch;
28582871
patch.openObject();
2859-
patch.add("version", VPackValue(LogicalCollection::VERSION_31));
2872+
patch.add("version", VPackValue(static_cast<int>(LogicalCollection::currentVersion())));
28602873
if (!name.empty() && name[0] == '_' && !slice.hasKey("isSystem")) {
28612874
// system collection?
28622875
patch.add("isSystem", VPackValue(true));
28632876
}
2877+
if (!uuid.empty()) {
2878+
bool valid = false;
2879+
NumberUtils::atoi_positive<uint64_t>(uuid.data(), uuid.data() + uuid.size(), valid);
2880+
if (valid) {
2881+
// globallyUniqueId is only numeric. This causes ambiguities later
2882+
// and can only happen for collections created with v3.3.0 (the GUID
2883+
// generation process was changed in v3.3.1 already to fix this issue).
2884+
// remove the globallyUniqueId so a new one will be generated server.side
2885+
patch.add(StaticStrings::DataSourceGuid, VPackSlice::nullSlice());
2886+
}
2887+
}
28642888
patch.add("objectId", VPackSlice::nullSlice());
28652889
patch.add("cid", VPackSlice::nullSlice());
28662890
patch.add("id", VPackSlice::nullSlice());

0 commit comments

Comments
 (0)
0