mirror of https://gitee.com/bigwinds/arangodb
Faulty implementation of checks for multiple preconditions in agency
This commit is contained in:
parent
4efb6aac7f
commit
de9618572c
|
@ -233,6 +233,8 @@ std::vector<bool> Store::apply (
|
||||||
// Check precondition
|
// Check precondition
|
||||||
bool Store::check (VPackSlice const& slice) const {
|
bool Store::check (VPackSlice const& slice) const {
|
||||||
|
|
||||||
|
LOG(WARN) << slice.toJson();
|
||||||
|
|
||||||
if (!slice.isObject()) { // Must be object
|
if (!slice.isObject()) { // Must be object
|
||||||
LOG_TOPIC(WARN, Logger::AGENCY)
|
LOG_TOPIC(WARN, Logger::AGENCY)
|
||||||
<< "Cannot check precondition: " << slice.toJson();
|
<< "Cannot check precondition: " << slice.toJson();
|
||||||
|
@ -240,6 +242,7 @@ bool Store::check (VPackSlice const& slice) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& precond : VPackObjectIterator(slice)) { // Preconditions
|
for (auto const& precond : VPackObjectIterator(slice)) { // Preconditions
|
||||||
|
LOG(WARN) << precond.value.toJson();
|
||||||
std::string path = precond.key.copyString();
|
std::string path = precond.key.copyString();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
Node node ("precond");
|
Node node ("precond");
|
||||||
|
@ -251,6 +254,7 @@ bool Store::check (VPackSlice const& slice) const {
|
||||||
|
|
||||||
if (precond.value.isObject()) {
|
if (precond.value.isObject()) {
|
||||||
for (auto const& op : VPackObjectIterator(precond.value)) {
|
for (auto const& op : VPackObjectIterator(precond.value)) {
|
||||||
|
LOG(WARN) << node.slice().toJson() << " " << op.key.copyString() << ":" << op.value.toJson();
|
||||||
std::string const& oper = op.key.copyString();
|
std::string const& oper = op.key.copyString();
|
||||||
if (oper == "old") { // old
|
if (oper == "old") { // old
|
||||||
if (node != op.value) {
|
if (node != op.value) {
|
||||||
|
@ -273,13 +277,16 @@ bool Store::check (VPackSlice const& slice) const {
|
||||||
<< "Non boolsh expression for 'oldEmpty' precondition";
|
<< "Non boolsh expression for 'oldEmpty' precondition";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
LOG(WARN) << found;
|
||||||
if (op.value.getBool() ? found : !found) {
|
if (op.value.getBool() ? found : !found) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return node == precond.value;
|
if (node != precond.value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1385,7 +1385,7 @@ function startInstanceAgency(instanceInfo, protocol, options,
|
||||||
|
|
||||||
const N = options.agencySize;
|
const N = options.agencySize;
|
||||||
if (options.agencyWaitForSync === undefined) {
|
if (options.agencyWaitForSync === undefined) {
|
||||||
options.agencyWaitForSync = true;
|
options.agencyWaitForSync = false;
|
||||||
}
|
}
|
||||||
const wfs = options.agencyWaitForSync;
|
const wfs = options.agencyWaitForSync;
|
||||||
|
|
||||||
|
|
|
@ -158,14 +158,32 @@ function agencyTestSuite () {
|
||||||
res = writeAgency([[{"/a/b/c":{"op":"set","new":14}},{"/a":{"old":{"b":{"c":13}}}}]]);
|
res = writeAgency([[{"/a/b/c":{"op":"set","new":14}},{"/a":{"old":{"b":{"c":13}}}}]]);
|
||||||
assertEqual(res.statusCode, 200);
|
assertEqual(res.statusCode, 200);
|
||||||
// multiple preconditions
|
// multiple preconditions
|
||||||
res = writeAgency([[{"/a":12},{"/a":{"oldEmpty":false}}]]);
|
res = writeAgency([[{"/a":1,"/b":true,"/c":"c"},{"/a":{"oldEmpty":false}}]]);
|
||||||
assertEqual(readAndCheck([["/a"]]), [{a:12}]);
|
assertEqual(readAndCheck([["/a","/b","c"]]), [{a:1,b:true,c:"c"}]);
|
||||||
res = writeAgency([[{"/a":13},{"/a":{"oldEmpty":false},"/a":{"oldEmpty":true}}]]);
|
res = writeAgency([[{"/a":2},{"/a":{"oldEmpty":false},"/b":{"oldEmpty":true}}]]);
|
||||||
assertEqual(res.statusCode, 412);
|
assertEqual(res.statusCode, 412);
|
||||||
assertEqual(readAndCheck([["/a"]]), [{a:12}]);
|
assertEqual(readAndCheck([["/a"]]), [{a:1}]);
|
||||||
res = writeAgency([[{"/a":13},{"/a":{"oldEmpty":true},"/a":{"oldEmpty":false}}]]);
|
res = writeAgency([[{"/a":2},{"/a":{"oldEmpty":true},"/b":{"oldEmpty":false}}]]);
|
||||||
assertEqual(res.statusCode, 412);
|
assertEqual(res.statusCode, 412);
|
||||||
assertEqual(readAndCheck([["/a"]]), [{a:12}]);
|
assertEqual(readAndCheck([["/a"]]), [{a:1}]);
|
||||||
|
res = writeAgency([[{"/a":2},{"/a":{"oldEmpty":false},"/b":{"oldEmpty":false},"/c":{"oldEmpty":true}}]]);
|
||||||
|
assertEqual(res.statusCode, 412);
|
||||||
|
assertEqual(readAndCheck([["/a"]]), [{a:1}]);
|
||||||
|
res = writeAgency([[{"/a":2},{"/a":{"oldEmpty":false},"/b":{"oldEmpty":false},"/c":{"oldEmpty":false}}]]);
|
||||||
|
assertEqual(res.statusCode, 200);
|
||||||
|
assertEqual(readAndCheck([["/a"]]), [{a:2}]);
|
||||||
|
res = writeAgency([[{"/a":3},{"/a":{"old":2},"/b":{"oldEmpty":false},"/c":{"oldEmpty":false}}]]);
|
||||||
|
assertEqual(res.statusCode, 200);
|
||||||
|
assertEqual(readAndCheck([["/a"]]), [{a:3}]);
|
||||||
|
res = writeAgency([[{"/a":2},{"/a":{"old":2},"/b":{"oldEmpty":false},"/c":{"oldEmpty":false}}]]);
|
||||||
|
assertEqual(res.statusCode, 412);
|
||||||
|
assertEqual(readAndCheck([["/a"]]), [{a:3}]);
|
||||||
|
res = writeAgency([[{"/a":2},{"/a":{"old":3},"/b":{"oldEmpty":false},"/c":{"isArray":true}}]]);
|
||||||
|
assertEqual(res.statusCode, 412);
|
||||||
|
assertEqual(readAndCheck([["/a"]]), [{a:3}]);
|
||||||
|
res = writeAgency([[{"/a":2},{"/a":{"old":3},"/b":{"oldEmpty":false},"/c":{"isArray":false}}]]);
|
||||||
|
assertEqual(res.statusCode, 200);
|
||||||
|
assertEqual(readAndCheck([["/a"]]), [{a:2}]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
.globl TRI_BlockCrc32_SSE42
|
.globl TRI_BlockCrc32_SSE42
|
||||||
.globl _TRI_BlockCrc32_SSE42
|
.globl _TRI_BlockCrc32_SSE42
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
.type TRI_BlockCrc32_SSE42, @function
|
// .type TRI_BlockCrc32_SSE42, @function
|
||||||
.type _TRI_BlockCrc32_SSE42, @function
|
// .type _TRI_BlockCrc32_SSE42, @function
|
||||||
#endif
|
#endif
|
||||||
TRI_BlockCrc32_SSE42:
|
TRI_BlockCrc32_SSE42:
|
||||||
_TRI_BlockCrc32_SSE42:
|
_TRI_BlockCrc32_SSE42:
|
||||||
|
@ -58,7 +58,7 @@ crca9:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
.size TRI_BlockCrc32_SSE42, .-TRI_BlockCrc32_SSE42
|
// .size TRI_BlockCrc32_SSE42, .-TRI_BlockCrc32_SSE42
|
||||||
.size _TRI_BlockCrc32_SSE42, .-_TRI_BlockCrc32_SSE42
|
// .size _TRI_BlockCrc32_SSE42, .-_TRI_BlockCrc32_SSE42
|
||||||
#endif
|
#endif
|
||||||
/* end of TRI_BlockCrc32_SSE42 */
|
/* end of TRI_BlockCrc32_SSE42 */
|
||||||
|
|
Loading…
Reference in New Issue