8000 Fix BTS-548 array index wrong optimization by neunhoef · Pull Request #14780 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Fix BTS-548 array index wrong optimization #14780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
v3.8.2 (XXXX-XX-XX)
-------------------

* Fixed a bug for array indexes on update of documents (BTS-548).

* Fixed BTS-562: reduce-extraction-to-projection optimization returns null for
one attribute if nested attributes are named the same.

Expand All @@ -14,8 +16,8 @@ v3.8.2 (XXXX-XX-XX)
trying to modify the list of collections (very unlikely and never observed
until now).

* Fix active failover, so that the new host actually has working
foxx services. (BTS-558)
* Fix active failover, so that the new host actually has working foxx services
(BTS-558).

* Fixed issue #14720: Bulk import ignores onDuplicate in 3.8.0.
The "onDuplicate" attribute was ignored by the `/_api/import` REST API when
Expand Down
9 changes: 9 additions & 0 deletions arangod/RocksDBEngine/RocksDBVPackIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,15 @@ namespace {

if (begin->shouldExpand &&
first.isArray() && second.isArray()) {
if (first.length() != second.length()) {
// Nonequal length, so there is a difference!
// We have to play this carefully here. It is possible that the
// set of values found is the same, but we must err on the side
// of caution in this case and use the slow path. Note in
// particular that the following code returns `true`, if one
// of the arrays is empty, which is not correct!
return false;
}
auto next = begin + 1;
VPackArrayIterator it1(first), it2(second);
while (it1.valid() && it2.valid()) {
Expand Down
70 changes: 69 additions & 1 deletion tests/js/server/shell/shell-array-index-noncluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,75 @@ function arraySkiplistIndexSuite () {
catch (err) {
assertEqual(errors.ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.code, err.errorNum);
}
}
},

////////////////////////////////////////////////////////////////////////////////
/// @brief test: Test update of an array index where entries are removed:
////////////////////////////////////////////////////////////////////////////////

testPersistentArrayIndexUpdates : function () {
collection.ensureIndex({type:"persistent", fields: ["a[*].b"], unique: true});

let meta = collection.insert({a: [{b:"xyz"}]});

try {
collection.insert({a: [{b:"xyz"}]});
fail();
}
catch (err) {
assertEqual(errors.ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.code, err.errorNum);
}

collection.update(meta._key, {a: []});

let meta2 = collection.insert({a: [{b:"xyz"}]}); // must work again

try {
collection.insert({a: [{b:"xyz"}]});
fail();
}
catch (err) {
assertEqual(errors.ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.code, err.errorNum);
}

collection.replace(meta2._key, {a: []});

collection.insert({a: [{b:"xyz"}]}); // must work again
},

////////////////////////////////////////////////////////////////////////////////
/// @brief test: Test update of an array index where entries are changed:
////////////////////////////////////////////////////////////////////////////////

testPersistentArrayIndexUpdates2 : function () {
collection.ensureIndex({type:"persistent", fields: ["a[*].b"], unique: true});

let meta = collection.insert({a: [{b:"xyz"}]});

try {
collection.insert({a: [{b:"xyz"}]});
fail();
}
catch (err) {
assertEqual(errors.ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.code, err.errorNum);
}

collection.update(meta._key, {a: [{b:"123"}]});

let meta2 = collection.insert({a: [{b:"xyz"}]}); // must work again

try {
collection.insert({a: [{b:"xyz"}]});
fail();
}
catch (err) {
assertEqual(errors.ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED.code, err.errorNum);
}

collection.replace(meta2._key, {a: [{b:"456"}]});

collection.insert({a: [{b:"xyz"}]}); // must work again
},

};
}
Expand Down
0