8000 Fix arangorestore API to create _rev on shard leader [BTS-1232]. (#18… · arangodb/arangodb@b5a5a51 · GitHub
[go: up one dir, main page]

Skip to content

Commit b5a5a51

Browse files
neunhoefKVS85
andauthored
Fix arangorestore API to create _rev on shard leader [BTS-1232]. (#18191)
* Backport from devel. * Update CHANGELOG --------- Co-authored-by: Vadim <vadim@arangodb.com>
1 parent a08b8e1 commit b5a5a51

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

CHANGELOG

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

4+
* Fixed a bug in the API used by `arangorestore`: On restore, a new _rev value
5+
is generated for each imported document to avoid clashes with previously
6+
present data. This must be created on the shard leader rather than the
7+
coordinator. The bug happened, when two coordinators were creating the same
8+
_rev value for two different documents concurrently.
9+
410
* Updated ArangoDB Starter to 0.15.7.
511

612
* Updated OpenSSL to 1.1.1t and OpenLDAP to 2.6.4.

arangod/RestHandler/RestReplicationHandler.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,11 +1531,14 @@ Result RestReplicationHandler::parseBatch(transaction::Methods& trx,
15311531
// prevent checking for _rev twice in the same document
15321532
checkRev = false;
15331533

1534-
char ridBuffer[arangodb::basics::maxUInt64StringSize];
1535-
RevisionId newRid = physical->newRevisionId();
1536-
1537-
documentsToInsert.add(it.key);
1538-
documentsToInsert.add(newRid.toValuePair(ridBuffer));
1534+
// We simply get rid of the `_rev` attribute here on the
1535+
// coordinator. We need to create a new value but it has to be
1536+
// unique in the shard, therefore the shard leader must create the
1537+
// value. If multiple coordinators would create a timestamp based
1538+
// _rev value concurrently, we could get a duplicate, which would
1539+
// lead to a clash on the actual shard leader and can lead to
1540+
// RocksDB conflicts or even data corruption between primary index
1541+
// and data in the documents column family.
15391542
} else {
15401543
// copy key/value verbatim
15411544
documentsToInsert.add(it.key);

0 commit comments

Comments
 (0)
0