1
0
Fork 0

Fix an agency bug found in Windows tests. (#9728)

* Fix agency bug found in Windows tests.
* CHANGELOG.
This commit is contained in:
Max Neunhöffer 2019-08-16 12:17:09 +02:00 committed by GitHub
parent e64080e207
commit b753c895e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 12 deletions

View File

@ -1,6 +1,8 @@
v3.5.1 (XXXX-XX-XX)
-------------------
* Fixed an agency bug found in Windows tests.
* Added initial support for wgs84 reference ellipsoid in GEO_DISTANCE through
third optional parameter to AQL function.

View File

@ -975,16 +975,27 @@ trans_ret_t Agent::transact(query_t const& queries) {
return trans_ret_t(false, NO_LEADER);
}
term_t currentTerm = term(); // this is the term we will be working with
// Check that we are actually still the leader:
if (!leading()) {
return trans_ret_t(false, NO_LEADER);
}
_tiLock.assertNotLockedByCurrentThread();
MUTEX_LOCKER(ioLocker, _ioLock);
for (const auto& query : VPackArrayIterator(qs)) {
// Check that we are actually still the leader:
if (!leading()) {
return trans_ret_t(false, NO_LEADER);
}
if (query[0].isObject()) {
check_ret_t res = _spearhead.applyTransaction(query);
if (res.successful()) {
maxind = (query.length() == 3 && query[2].isString())
? _state.logLeaderSingle(query[0], term(), query[2].copyString())
: _state.logLeaderSingle(query[0], term());
? _state.logLeaderSingle(query[0], currentTerm, query[2].copyString())
: _state.logLeaderSingle(query[0], currentTerm);
ret->add(VPackValue(maxind));
} else {
_spearhead.read(res.failed->slice(), *ret);
@ -1134,6 +1145,13 @@ write_ret_t Agent::write(query_t const& query, WriteMode const& wmode) {
npacks++;
}
term_t currentTerm = term(); // this is the term we will be working with
// Check that we are actually still the leader:
if (!leading()) {
return write_ret_t(false, NO_LEADER);
}
// Apply to spearhead and get indices for log entries
// Avoid keeping lock indefinitely
for (size_t i = 0, l = 0; i < npacks; ++i) {
@ -1151,11 +1169,16 @@ write_ret_t Agent::write(query_t const& query, WriteMode const& wmode) {
return write_ret_t(false, NO_LEADER);
}
// Check that we are actually still the leader:
if (!leading()) {
return write_ret_t(false, NO_LEADER);
}
_tiLock.assertNotLockedByCurrentThread();
MUTEX_LOCKER(ioLocker, _ioLock);
applied = _spearhead.applyTransactions(chunk, wmode);
auto tmp = _state.logLeaderMulti(chunk, applied, term());
auto tmp = _state.logLeaderMulti(chunk, applied, currentTerm);
indices.insert(indices.end(), tmp.begin(), tmp.end());
}
}

View File

@ -1453,12 +1453,10 @@ std::vector<index_t> State::inquire(query_t const& query) const {
auto ret = _clientIdLookupTable.equal_range(i.copyString());
index_t index = 0;
// Look for the maximum index:
for (auto it = ret.first; it != ret.second; ++it) {
if (it->second < _log[0].index) {
continue;
}
if (index < _log.at(it->second - _cur).index) {
index = _log.at(it->second - _cur).index;
if (it->second > index) {
index = it->second;
}
}
result.push_back(index);

View File

@ -127,7 +127,8 @@ static void sendLeaderChangeRequests(std::vector<ServerID> const& currentServers
if (srv == sid) {
continue; // ignore ourself
}
LOG_DEVEL << "Sending " << bodyBuilder.toJson() << " to " << srv;
LOG_TOPIC("42516", DEBUG, Logger::MAINTENANCE)
<< "Sending " << bodyBuilder.toJson() << " to " << srv;
requests.emplace_back("server:" + srv, RequestType::PUT, url, body);
}

View File

@ -143,8 +143,13 @@ function agencyTestSuite () {
}
});
var startTime = new Date();
while (true) {
if (new Date() - startTime > 600000) {
assertTrue(false, "Hit global timeout of 10 minutes in accessAgency.");
}
if (!inquire) {
res = request({url: agencyLeader + "/_api/agency/" + api,
method: "POST", followRedirect: false,
@ -152,6 +157,7 @@ function agencyTestSuite () {
headers: {"Content-Type": "application/json"},
timeout: timeout /* essentially for the huge trx package
running under ASAN in the CI */ });
require('console').topic("agency=debug", 'Sent out agency request, statusCode:', res.statusCode);
} else { // inquire. Remove successful commits. For later retries
res = request({url: agencyLeader + "/_api/agency/inquire",
method: "POST", followRedirect: false,
@ -159,6 +165,7 @@ function agencyTestSuite () {
headers: {"Content-Type": "application/json"},
timeout: timeout
});
require('console').topic("agency=info", 'Sent out agency inquiry, statusCode:', res.statusCode);
}
if (res.statusCode === 307) {
@ -173,8 +180,9 @@ function agencyTestSuite () {
}
require('console').topic("agency=info", 'Redirected to ' + agencyLeader);
continue;
} else if (res.statusCode === 503) {
require('console').topic("agency=info", 'Waiting for leader ... ');
} else if (res.statusCode === 503 || res.statusCode === 500) {
// 503 covers service not available and 500 covers timeout
require('console').topic("agency=info", 'Got status code', res.statusCode, ', waiting for leader ... ');
if (clientIds.length > 0 && api === 'write') {
inquire = true;
}
@ -188,15 +196,23 @@ function agencyTestSuite () {
var done = 0;
res.bodyParsed = JSON.parse(res.body);
res.bodyParsed.results.forEach(function (index) {
var noZeroYet = true;
if (index > 0) {
done++;
assertTrue(noZeroYet);
} else {
noZeroYet = false;
}
});
require('console').topic("agency=info", 'Inquiry analysis: done=', done, ' body:', res.body);
if (done === clientIds.length) {
require('console').topic("agency=info", 'Inquiry analysis, accepting result as good!');
break;
} else {
list = list.slice(done);
clientIds = clientIds.slice(done);
inquire = false;
require('console').topic("agency=info", 'Inquiry analysis: have accepted', done, 'transactions as done, continuing with this list:', JSON.stringify(list));
}
}
try {
@ -231,7 +247,7 @@ function agencyTestSuite () {
let trxs = [];
for (i = start; i < start + count; ++i) {
let key = "/key"+i;
let trx = [{},{},"clientid" + counter++];
let trx = [{},{},"clientid" + start + counter++];
trx[0][key] = "value" + i;
trxs.push(trx);
if (trxs.length >= 200 || i === start + count - 1) {