diff --git a/arangod/Agency/AddFollower.cpp b/arangod/Agency/AddFollower.cpp index ffc5129d03..7528c8d10c 100644 --- a/arangod/Agency/AddFollower.cpp +++ b/arangod/Agency/AddFollower.cpp @@ -242,6 +242,8 @@ bool AddFollower::start() { pending.openObject(); pending.add(_agencyPrefix + curPath, VPackValue(VPackValueType::Object)); pending.add("old", current); + pending.close(); + // --- Check that Plan servers are as we expect pending.add(_agencyPrefix + planPath, VPackValue(VPackValueType::Object)); pending.add("old", planned); pending.close(); diff --git a/arangod/Agency/FailedLeader.cpp b/arangod/Agency/FailedLeader.cpp index dc9caad1d6..2b5f05acd1 100644 --- a/arangod/Agency/FailedLeader.cpp +++ b/arangod/Agency/FailedLeader.cpp @@ -112,6 +112,7 @@ bool FailedLeader::start() { curColPrefix + _database + "/" + _collection + "/" + _shard + "/servers"; Node const& current = _snapshot(curPath); + Node const& planned = _snapshot(planPath); if (current.slice().length() == 1) { LOG_TOPIC(ERR, Logger::AGENCY) @@ -180,13 +181,19 @@ bool FailedLeader::start() { pending.close(); - // Precondition + // Preconditions + // --- Check that Current servers are as we expect pending.openObject(); pending.add(_agencyPrefix + curPath, VPackValue(VPackValueType::Object)); pending.add("old", current.slice()); pending.close(); + // --- Check that Current servers are as we expect + pending.add(_agencyPrefix + planPath, VPackValue(VPackValueType::Object)); + pending.add("old", planned.slice()); + pending.close(); + // --- Check if shard is not blocked pending.add(_agencyPrefix + blockedShardsPrefix + _shard, VPackValue(VPackValueType::Object)); diff --git a/arangod/GeneralServer/GeneralCommTask.cpp b/arangod/GeneralServer/GeneralCommTask.cpp index 13f48d94d1..bcd5ece0a7 100644 --- a/arangod/GeneralServer/GeneralCommTask.cpp +++ b/arangod/GeneralServer/GeneralCommTask.cpp @@ -77,6 +77,8 @@ GeneralCommTask::~GeneralCommTask() { // ----------------------------------------------------------------------------- void GeneralCommTask::setStatistics(uint64_t id, RequestStatistics* stat) { + MUTEX_LOCKER(locker, _statisticsMutex); + auto iter = _statisticsMap.find(id); if (iter == _statisticsMap.end()) { @@ -191,6 +193,8 @@ RequestStatistics* GeneralCommTask::acquireStatistics(uint64_t id) { } RequestStatistics* GeneralCommTask::statistics(uint64_t id) { + MUTEX_LOCKER(locker, _statisticsMutex); + auto iter = _statisticsMap.find(id); if (iter == _statisticsMap.end()) { @@ -201,6 +205,8 @@ RequestStatistics* GeneralCommTask::statistics(uint64_t id) { } RequestStatistics* GeneralCommTask::stealStatistics(uint64_t id) { + MUTEX_LOCKER(locker, _statisticsMutex); + auto iter = _statisticsMap.find(id); if (iter == _statisticsMap.end()) { diff --git a/arangod/GeneralServer/HttpCommTask.cpp b/arangod/GeneralServer/HttpCommTask.cpp index 1425f6d91d..2581b85ad1 100644 --- a/arangod/GeneralServer/HttpCommTask.cpp +++ b/arangod/GeneralServer/HttpCommTask.cpp @@ -264,7 +264,6 @@ bool HttpCommTask::processRead(double startTime) { _readBuffer.length() - 11); commTask->processRead(startTime); commTask->start(); - // statistics?! return false; } @@ -364,10 +363,7 @@ bool HttpCommTask::processRead(double startTime) { // (original request object gets deleted before responding) _requestType = _incompleteRequest->requestType(); - if (stat == nullptr) { - stat = statistics(1UL); - } - + stat = statistics(1UL); RequestStatistics::SET_REQUEST_TYPE(stat, _requestType); // handle different HTTP methods @@ -494,12 +490,9 @@ bool HttpCommTask::processRead(double startTime) { return false; } - if (stat == nullptr) { - stat = statistics(1UL); - } - auto bytes = _bodyPosition - _startPosition + _bodyLength; + stat = statistics(1UL); RequestStatistics::SET_READ_END(stat); RequestStatistics::ADD_RECEIVED_BYTES(stat, bytes); diff --git a/arangod/GeneralServer/RestHandler.h b/arangod/GeneralServer/RestHandler.h index 80edc08a7e..9c9a652f8b 100644 --- a/arangod/GeneralServer/RestHandler.h +++ b/arangod/GeneralServer/RestHandler.h @@ -52,7 +52,7 @@ class RestHandler : public std::enable_shared_from_this { public: RestHandler(GeneralRequest*, GeneralResponse*); - ~RestHandler(); + virtual ~RestHandler(); public: uint64_t handlerId() const { return _handlerId; } diff --git a/arangod/Statistics/ConnectionStatistics.h b/arangod/Statistics/ConnectionStatistics.h index fca5f44a31..e445b489b0 100644 --- a/arangod/Statistics/ConnectionStatistics.h +++ b/arangod/Statistics/ConnectionStatistics.h @@ -66,7 +66,7 @@ class ConnectionStatistics { _error = false; } - static size_t const QUEUE_SIZE = 1000; + static size_t const QUEUE_SIZE = 5000; static Mutex _dataLock; diff --git a/arangod/Statistics/RequestStatistics.cpp b/arangod/Statistics/RequestStatistics.cpp index 0064932ecb..cfeae62b5e 100644 --- a/arangod/Statistics/RequestStatistics.cpp +++ b/arangod/Statistics/RequestStatistics.cpp @@ -179,15 +179,14 @@ void RequestStatistics::process(RequestStatistics* statistics) { void RequestStatistics::release() { TRI_ASSERT(!_released); + TRI_ASSERT(!_inQueue); if (!_ignore) { - TRI_ASSERT(!_inQueue); _inQueue = true; bool ok = _finishedList.push(this); TRI_ASSERT(ok); } else { reset(); - _released = true; bool ok = _freeList.push(this); TRI_ASSERT(ok); } diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/databaseView.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/databaseView.js index 34ed03c3e9..4f5b47a3ae 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/databaseView.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/databaseView.js @@ -59,31 +59,38 @@ }, render: function () { + var self = this; + var callback = function (error, db) { if (error) { arangoHelper.arangoError('DB', 'Could not get current db properties'); } else { - this.currentDB = db; - // sorting - this.collection.sort(); + self.currentDB = db; - $(this.el).html(this.template.render({ - collection: this.collection, - searchString: '', - currentDB: this.currentDB - })); + self.collection.fetch({ + success: function () { + // sorting + self.collection.sort(); - if (this.dropdownVisible === true) { - $('#dbSortDesc').attr('checked', this.collection.sortOptions.desc); - $('#databaseToggle').toggleClass('activated'); - $('#databaseDropdown2').show(); - } + $(self.el).html(self.template.render({ + collection: self.collection, + searchString: '', + currentDB: self.currentDB + })); - arangoHelper.setCheckboxStatus('#databaseDropdown'); + if (self.dropdownVisible === true) { + $('#dbSortDesc').attr('checked', self.collection.sortOptions.desc); + $('#databaseToggle').toggleClass('activated'); + $('#databaseDropdown2').show(); + } - this.replaceSVGs(); + arangoHelper.setCheckboxStatus('#databaseDropdown'); + + self.replaceSVGs(); + } + }); } - }.bind(this); + }; this.collection.getCurrentDatabase(callback); diff --git a/lib/SimpleHttpClient/SimpleHttpClient.cpp b/lib/SimpleHttpClient/SimpleHttpClient.cpp index e10e535368..d5dcafcd40 100644 --- a/lib/SimpleHttpClient/SimpleHttpClient.cpp +++ b/lib/SimpleHttpClient/SimpleHttpClient.cpp @@ -338,7 +338,11 @@ SimpleHttpResult* SimpleHttpClient::doRequest( break; } - else if (_state == IN_READ_BODY && !_result->hasContentLength()) { + if (_state == IN_READ_HEADER) { + processHeader(); + } + + if (_state == IN_READ_BODY && !_result->hasContentLength()) { // If we are reading the body and no content length was // found in the header, then we must read until no more // progress is made (but without an error), this then means @@ -346,24 +350,18 @@ SimpleHttpResult* SimpleHttpClient::doRequest( // process the body one more time: _result->setContentLength(_readBuffer.length() - _readBufferOffset); processBody(); + } else if (_state == IN_READ_BODY) { + processBody(); + } - if (_state != FINISHED) { - // If the body was not fully found we give up: - this->close(); - _state = DEAD; - setErrorMessage("Got unexpected response from remote"); - } - - break; + if (_state != FINISHED) { + // If the body was not fully found we give up: + this->close(); + _state = DEAD; + setErrorMessage("Got unexpected response from remote"); } - else { - // In all other cases of closed connection, we are doomed: - this->close(); - _state = DEAD; - setErrorMessage("Got unexpected response from remote"); - break; - } + break; } // the connection is still alive: