mirror of https://gitee.com/bigwinds/arangodb
Create log topics for AgencyComm and Heartbeat.
This commit is contained in:
parent
9aa6df528c
commit
0b068fa3e4
|
@ -37,7 +37,6 @@
|
||||||
#include "Cluster/ServerState.h"
|
#include "Cluster/ServerState.h"
|
||||||
#include "Endpoint/Endpoint.h"
|
#include "Endpoint/Endpoint.h"
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "Logger/Logger.h"
|
|
||||||
#include "Random/RandomGenerator.h"
|
#include "Random/RandomGenerator.h"
|
||||||
#include "Rest/HttpRequest.h"
|
#include "Rest/HttpRequest.h"
|
||||||
#include "Rest/HttpResponse.h"
|
#include "Rest/HttpResponse.h"
|
||||||
|
@ -593,7 +592,8 @@ bool AgencyComm::tryConnect() {
|
||||||
|
|
||||||
// mop: not sure if a timeout makes sense here
|
// mop: not sure if a timeout makes sense here
|
||||||
while (true) {
|
while (true) {
|
||||||
LOG(INFO) << "Trying to find an active agency. Checking " << endpointsStr;
|
LOG_TOPIC(INFO, Logger::AGENCYCOMM)
|
||||||
|
<< "Trying to find an active agency. Checking " << endpointsStr;
|
||||||
std::list<AgencyEndpoint*>::iterator it = _globalEndpoints.begin();
|
std::list<AgencyEndpoint*>::iterator it = _globalEndpoints.begin();
|
||||||
|
|
||||||
while (it != _globalEndpoints.end()) {
|
while (it != _globalEndpoints.end()) {
|
||||||
|
@ -862,8 +862,8 @@ void AgencyComm::disconnect() {
|
||||||
|
|
||||||
bool AgencyComm::addEndpoint(std::string const& endpointSpecification,
|
bool AgencyComm::addEndpoint(std::string const& endpointSpecification,
|
||||||
bool toFront) {
|
bool toFront) {
|
||||||
LOG(TRACE) << "adding global agency-endpoint '" << endpointSpecification
|
LOG_TOPIC(TRACE, Logger::AGENCYCOMM)
|
||||||
<< "'";
|
<< "adding global agency-endpoint '" << endpointSpecification << "'";
|
||||||
|
|
||||||
{
|
{
|
||||||
WRITE_LOCKER(writeLocker, AgencyComm::_globalLock);
|
WRITE_LOCKER(writeLocker, AgencyComm::_globalLock);
|
||||||
|
@ -1048,7 +1048,8 @@ bool AgencyComm::setPrefix(std::string const& prefix) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(TRACE) << "setting agency-prefix to '" << prefix << "'";
|
LOG_TOPIC(TRACE, Logger::AGENCYCOMM)
|
||||||
|
<< "setting agency-prefix to '" << prefix << "'";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1284,8 +1285,8 @@ AgencyCommResult AgencyComm::getValues(std::string const& key, bool recursive) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (node.isArray()) {
|
} else if (node.isArray()) {
|
||||||
LOG(ERR) << node.toJson();
|
LOG_TOPIC(ERR, Logger::AGENCYCOMM) << node.toJson();
|
||||||
LOG(ERR) << "Oops...TODO array unexpected";
|
LOG_TOPIC(ERR, Logger::AGENCYCOMM) << "Oops...TODO array unexpected";
|
||||||
} else {
|
} else {
|
||||||
builder.add("value", node);
|
builder.add("value", node);
|
||||||
}
|
}
|
||||||
|
@ -1333,13 +1334,16 @@ AgencyCommResult AgencyComm::getValues(std::string const& key, bool recursive) {
|
||||||
VPackStringSink sink(&result._body);
|
VPackStringSink sink(&result._body);
|
||||||
VPackDumper::dump(s, &sink, &dumperOptions);
|
VPackDumper::dump(s, &sink, &dumperOptions);
|
||||||
|
|
||||||
LOG(TRACE) << "Created fake etcd node" << result._body;
|
LOG_TOPIC(TRACE, Logger::AGENCYCOMM)
|
||||||
|
<< "Created fake etcd node" << result._body;
|
||||||
result._statusCode = 200;
|
result._statusCode = 200;
|
||||||
} catch(std::exception &e) {
|
} catch(std::exception &e) {
|
||||||
LOG(ERR) << "Error transforming result. " << e.what();
|
LOG_TOPIC(ERR, Logger::AGENCYCOMM)
|
||||||
|
<< "Error transforming result. " << e.what();
|
||||||
result.clear();
|
result.clear();
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
LOG(ERR) << "Error transforming result. Out of memory";
|
LOG_TOPIC(ERR, Logger::AGENCYCOMM)
|
||||||
|
<< "Error transforming result. Out of memory";
|
||||||
result.clear();
|
result.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1390,10 +1394,12 @@ AgencyCommResult AgencyComm::getValues2(std::string const& key) {
|
||||||
result._statusCode = 200;
|
result._statusCode = 200;
|
||||||
|
|
||||||
} catch(std::exception &e) {
|
} catch(std::exception &e) {
|
||||||
LOG(ERR) << "Error transforming result. " << e.what();
|
LOG_TOPIC(ERR, Logger::AGENCYCOMM)
|
||||||
|
<< "Error transforming result. " << e.what();
|
||||||
result.clear();
|
result.clear();
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
LOG(ERR) << "Error transforming result. Out of memory";
|
LOG_TOPIC(ERR, Logger::AGENCYCOMM)
|
||||||
|
<< "Error transforming result. Out of memory";
|
||||||
result.clear();
|
result.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1576,7 +1582,8 @@ uint64_t AgencyComm::uniqid(uint64_t count, double timeout) {
|
||||||
{prefixStripped(), "Sync", "LatestID"}));
|
{prefixStripped(), "Sync", "LatestID"}));
|
||||||
|
|
||||||
if (!(oldSlice.isSmallInt() || oldSlice.isUInt())) {
|
if (!(oldSlice.isSmallInt() || oldSlice.isUInt())) {
|
||||||
LOG(WARN) << "Sync/LatestID in agency is not an unsigned integer, fixing...";
|
LOG_TOPIC(WARN, Logger::AGENCYCOMM)
|
||||||
|
<< "Sync/LatestID in agency is not an unsigned integer, fixing...";
|
||||||
try {
|
try {
|
||||||
VPackBuilder builder;
|
VPackBuilder builder;
|
||||||
builder.add(VPackValue(0));
|
builder.add(VPackValue(0));
|
||||||
|
@ -1866,10 +1873,12 @@ AgencyCommResult AgencyComm::sendTransactionWithFailover(
|
||||||
result._statusCode = 200;
|
result._statusCode = 200;
|
||||||
|
|
||||||
} catch(std::exception &e) {
|
} catch(std::exception &e) {
|
||||||
LOG(ERR) << "Error transforming result. " << e.what();
|
LOG_TOPIC(ERR, Logger::AGENCYCOMM)
|
||||||
|
<< "Error transforming result. " << e.what();
|
||||||
result.clear();
|
result.clear();
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
LOG(ERR) << "Error transforming result. Out of memory";
|
LOG_TOPIC(ERR, Logger::AGENCYCOMM)
|
||||||
|
<< "Error transforming result. Out of memory";
|
||||||
result.clear();
|
result.clear();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1964,7 +1973,8 @@ AgencyCommResult AgencyComm::sendWithFailover(
|
||||||
if (!AgencyComm::hasEndpoint(endpoint)) {
|
if (!AgencyComm::hasEndpoint(endpoint)) {
|
||||||
AgencyComm::addEndpoint(endpoint, true);
|
AgencyComm::addEndpoint(endpoint, true);
|
||||||
|
|
||||||
LOG(INFO) << "adding agency-endpoint '" << endpoint << "'";
|
LOG_TOPIC(INFO, Logger::AGENCYCOMM)
|
||||||
|
<< "adding agency-endpoint '" << endpoint << "'";
|
||||||
|
|
||||||
// re-check the new endpoint
|
// re-check the new endpoint
|
||||||
if (AgencyComm::hasEndpoint(endpoint)) {
|
if (AgencyComm::hasEndpoint(endpoint)) {
|
||||||
|
@ -1972,7 +1982,8 @@ AgencyCommResult AgencyComm::sendWithFailover(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(ERR) << "found redirection to unknown endpoint '" << endpoint
|
LOG_TOPIC(ERR, Logger::AGENCYCOMM)
|
||||||
|
<< "found redirection to unknown endpoint '" << endpoint
|
||||||
<< "'. Will not follow!";
|
<< "'. Will not follow!";
|
||||||
|
|
||||||
// this is an error
|
// this is an error
|
||||||
|
@ -2029,7 +2040,8 @@ AgencyCommResult AgencyComm::send(
|
||||||
result._connected = false;
|
result._connected = false;
|
||||||
result._statusCode = 0;
|
result._statusCode = 0;
|
||||||
|
|
||||||
LOG(TRACE) << "sending " << arangodb::HttpRequest::translateMethod(method)
|
LOG_TOPIC(TRACE, Logger::AGENCYCOMM)
|
||||||
|
<< "sending " << arangodb::HttpRequest::translateMethod(method)
|
||||||
<< " request to agency at endpoint '"
|
<< " request to agency at endpoint '"
|
||||||
<< connection->getEndpoint()->specification() << "', url '" << url
|
<< connection->getEndpoint()->specification() << "', url '" << url
|
||||||
<< "': " << body;
|
<< "': " << body;
|
||||||
|
@ -2052,7 +2064,7 @@ AgencyCommResult AgencyComm::send(
|
||||||
if (response == nullptr) {
|
if (response == nullptr) {
|
||||||
connection->disconnect();
|
connection->disconnect();
|
||||||
result._message = "could not send request to agency";
|
result._message = "could not send request to agency";
|
||||||
LOG(TRACE) << "sending request to agency failed";
|
LOG_TOPIC(TRACE, Logger::AGENCYCOMM) << "sending request to agency failed";
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2060,7 +2072,7 @@ AgencyCommResult AgencyComm::send(
|
||||||
if (!response->isComplete()) {
|
if (!response->isComplete()) {
|
||||||
connection->disconnect();
|
connection->disconnect();
|
||||||
result._message = "sending request to agency failed";
|
result._message = "sending request to agency failed";
|
||||||
LOG(TRACE) << "sending request to agency failed";
|
LOG_TOPIC(TRACE, Logger::AGENCYCOMM) << "sending request to agency failed";
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2074,7 +2086,8 @@ AgencyCommResult AgencyComm::send(
|
||||||
bool found = false;
|
bool found = false;
|
||||||
result._location = response->getHeaderField("location", found);
|
result._location = response->getHeaderField("location", found);
|
||||||
|
|
||||||
LOG(TRACE) << "redirecting to location: '" << result._location << "'";
|
LOG_TOPIC(TRACE, Logger::AGENCYCOMM)
|
||||||
|
<< "redirecting to location: '" << result._location << "'";
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
// a 307 without a location header does not make any sense
|
// a 307 without a location header does not make any sense
|
||||||
|
@ -2090,7 +2103,8 @@ AgencyCommResult AgencyComm::send(
|
||||||
result._body = std::string(sb.c_str(), sb.length());
|
result._body = std::string(sb.c_str(), sb.length());
|
||||||
result._statusCode = response->getHttpReturnCode();
|
result._statusCode = response->getHttpReturnCode();
|
||||||
|
|
||||||
LOG(TRACE) << "request to agency returned status code " << result._statusCode
|
LOG_TOPIC(TRACE, Logger::AGENCYCOMM)
|
||||||
|
<< "request to agency returned status code " << result._statusCode
|
||||||
<< ", message: '" << result._message << "', body: '"
|
<< ", message: '" << result._message << "', body: '"
|
||||||
<< result._body << "'";
|
<< result._body << "'";
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,8 @@ void HeartbeatThread::run() {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void HeartbeatThread::runDBServer() {
|
void HeartbeatThread::runDBServer() {
|
||||||
LOG(TRACE) << "starting heartbeat thread (DBServer version)";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT)
|
||||||
|
<< "starting heartbeat thread (DBServer version)";
|
||||||
|
|
||||||
// convert timeout to seconds
|
// convert timeout to seconds
|
||||||
double const interval = (double)_interval / 1000.0 / 1000.0;
|
double const interval = (double)_interval / 1000.0 / 1000.0;
|
||||||
|
@ -116,7 +117,8 @@ void HeartbeatThread::runDBServer() {
|
||||||
std::function<bool(VPackSlice const& result)> updatePlan = [&](
|
std::function<bool(VPackSlice const& result)> updatePlan = [&](
|
||||||
VPackSlice const& result) {
|
VPackSlice const& result) {
|
||||||
if (!result.isNumber()) {
|
if (!result.isNumber()) {
|
||||||
LOG(ERR) << "Plan Version is not a number! " << result.toJson();
|
LOG_TOPIC(ERR, Logger::HEARTBEAT)
|
||||||
|
<< "Plan Version is not a number! " << result.toJson();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint64_t version = result.getNumber<uint64_t>();
|
uint64_t version = result.getNumber<uint64_t>();
|
||||||
|
@ -126,7 +128,8 @@ void HeartbeatThread::runDBServer() {
|
||||||
MUTEX_LOCKER(mutexLocker, _statusLock);
|
MUTEX_LOCKER(mutexLocker, _statusLock);
|
||||||
if (version > _desiredVersions.plan) {
|
if (version > _desiredVersions.plan) {
|
||||||
_desiredVersions.plan = version;
|
_desiredVersions.plan = version;
|
||||||
LOG(DEBUG) << "Desired Current Version is now " << _desiredVersions.plan;
|
LOG_TOPIC(DEBUG, Logger::HEARTBEAT)
|
||||||
|
<< "Desired Current Version is now " << _desiredVersions.plan;
|
||||||
doSync = true;
|
doSync = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +148,8 @@ void HeartbeatThread::runDBServer() {
|
||||||
while (!registered) {
|
while (!registered) {
|
||||||
registered = _agencyCallbackRegistry->registerCallback(planAgencyCallback);
|
registered = _agencyCallbackRegistry->registerCallback(planAgencyCallback);
|
||||||
if (!registered) {
|
if (!registered) {
|
||||||
LOG(ERR) << "Couldn't register plan change in agency!";
|
LOG_TOPIC(ERR, Logger::HEARTBEAT)
|
||||||
|
<< "Couldn't register plan change in agency!";
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,7 +159,7 @@ void HeartbeatThread::runDBServer() {
|
||||||
int currentCount = currentCountStart;
|
int currentCount = currentCountStart;
|
||||||
|
|
||||||
while (!isStopping()) {
|
while (!isStopping()) {
|
||||||
LOG(DEBUG) << "sending heartbeat to agency";
|
LOG_TOPIC(DEBUG, Logger::HEARTBEAT) << "sending heartbeat to agency";
|
||||||
|
|
||||||
double const start = TRI_microtime();
|
double const start = TRI_microtime();
|
||||||
|
|
||||||
|
@ -171,7 +175,8 @@ void HeartbeatThread::runDBServer() {
|
||||||
currentCount = currentCountStart;
|
currentCount = currentCountStart;
|
||||||
|
|
||||||
// send an initial GET request to Sync/Commands/my-id
|
// send an initial GET request to Sync/Commands/my-id
|
||||||
LOG(TRACE) << "Looking at Sync/Commands/" + _myId;
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT)
|
||||||
|
<< "Looking at Sync/Commands/" + _myId;
|
||||||
|
|
||||||
AgencyCommResult result =
|
AgencyCommResult result =
|
||||||
_agency.getValues2("Sync/Commands/" + _myId);
|
_agency.getValues2("Sync/Commands/" + _myId);
|
||||||
|
@ -184,17 +189,19 @@ void HeartbeatThread::runDBServer() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(TRACE) << "Refetching Current/Version...";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT) << "Refetching Current/Version...";
|
||||||
AgencyCommResult res = _agency.getValues2("Current/Version");
|
AgencyCommResult res = _agency.getValues2("Current/Version");
|
||||||
if (!res.successful()) {
|
if (!res.successful()) {
|
||||||
LOG(ERR) << "Could not read Current/Version from agency.";
|
LOG_TOPIC(ERR, Logger::HEARTBEAT)
|
||||||
|
<< "Could not read Current/Version from agency.";
|
||||||
} else {
|
} else {
|
||||||
VPackSlice s
|
VPackSlice s
|
||||||
= res.slice()[0].get(std::vector<std::string>(
|
= res.slice()[0].get(std::vector<std::string>(
|
||||||
{_agency.prefixStripped(), std::string("Current"),
|
{_agency.prefixStripped(), std::string("Current"),
|
||||||
std::string("Version")}));
|
std::string("Version")}));
|
||||||
if (!s.isInteger()) {
|
if (!s.isInteger()) {
|
||||||
LOG(ERR) << "Current/Version in agency is not an integer.";
|
LOG_TOPIC(ERR, Logger::HEARTBEAT)
|
||||||
|
<< "Current/Version in agency is not an integer.";
|
||||||
} else {
|
} else {
|
||||||
uint64_t currentVersion = 0;
|
uint64_t currentVersion = 0;
|
||||||
try {
|
try {
|
||||||
|
@ -202,13 +209,15 @@ void HeartbeatThread::runDBServer() {
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
if (currentVersion == 0) {
|
if (currentVersion == 0) {
|
||||||
LOG(ERR) << "Current/Version in agency is 0.";
|
LOG_TOPIC(ERR, Logger::HEARTBEAT)
|
||||||
|
<< "Current/Version in agency is 0.";
|
||||||
} else {
|
} else {
|
||||||
{
|
{
|
||||||
MUTEX_LOCKER(mutexLocker, _statusLock);
|
MUTEX_LOCKER(mutexLocker, _statusLock);
|
||||||
if (currentVersion > _desiredVersions.current) {
|
if (currentVersion > _desiredVersions.current) {
|
||||||
_desiredVersions.current = currentVersion;
|
_desiredVersions.current = currentVersion;
|
||||||
LOG(DEBUG) << "Found greater Current/Version in agency.";
|
LOG_TOPIC(DEBUG, Logger::HEARTBEAT)
|
||||||
|
<< "Found greater Current/Version in agency.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
syncDBServerStatusQuo();
|
syncDBServerStatusQuo();
|
||||||
|
@ -224,7 +233,7 @@ void HeartbeatThread::runDBServer() {
|
||||||
double remain = interval - (TRI_microtime() - start);
|
double remain = interval - (TRI_microtime() - start);
|
||||||
// mop: execute at least once
|
// mop: execute at least once
|
||||||
do {
|
do {
|
||||||
LOG(TRACE) << "Entering update loop";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT) << "Entering update loop";
|
||||||
|
|
||||||
bool wasNotified;
|
bool wasNotified;
|
||||||
{
|
{
|
||||||
|
@ -238,7 +247,7 @@ void HeartbeatThread::runDBServer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wasNotified) {
|
if (!wasNotified) {
|
||||||
LOG(TRACE) << "Lock reached timeout";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT) << "Lock reached timeout";
|
||||||
planAgencyCallback->refetchAndUpdate(true);
|
planAgencyCallback->refetchAndUpdate(true);
|
||||||
} else {
|
} else {
|
||||||
// mop: a plan change returned successfully...
|
// mop: a plan change returned successfully...
|
||||||
|
@ -263,7 +272,8 @@ void HeartbeatThread::runDBServer() {
|
||||||
}
|
}
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
LOG(TRACE) << "stopped heartbeat thread (DBServer version)";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT)
|
||||||
|
<< "stopped heartbeat thread (DBServer version)";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -271,7 +281,8 @@ void HeartbeatThread::runDBServer() {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void HeartbeatThread::runCoordinator() {
|
void HeartbeatThread::runCoordinator() {
|
||||||
LOG(TRACE) << "starting heartbeat thread (coordinator version)";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT)
|
||||||
|
<< "starting heartbeat thread (coordinator version)";
|
||||||
|
|
||||||
uint64_t oldUserVersion = 0;
|
uint64_t oldUserVersion = 0;
|
||||||
|
|
||||||
|
@ -286,7 +297,7 @@ void HeartbeatThread::runCoordinator() {
|
||||||
setReady();
|
setReady();
|
||||||
|
|
||||||
while (!isStopping()) {
|
while (!isStopping()) {
|
||||||
LOG(TRACE) << "sending heartbeat to agency";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT) << "sending heartbeat to agency";
|
||||||
|
|
||||||
double const start = TRI_microtime();
|
double const start = TRI_microtime();
|
||||||
// send our state to the agency.
|
// send our state to the agency.
|
||||||
|
@ -305,9 +316,11 @@ void HeartbeatThread::runCoordinator() {
|
||||||
AgencyCommResult result = _agency.sendTransactionWithFailover(trx);
|
AgencyCommResult result = _agency.sendTransactionWithFailover(trx);
|
||||||
|
|
||||||
if (!result.successful()) {
|
if (!result.successful()) {
|
||||||
LOG(WARN) << "Heartbeat: Could not read from agency!";
|
LOG_TOPIC(WARN, Logger::HEARTBEAT)
|
||||||
|
<< "Heartbeat: Could not read from agency!";
|
||||||
} else {
|
} else {
|
||||||
LOG(TRACE) << "Looking at Sync/Commands/" + _myId;
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT)
|
||||||
|
<< "Looking at Sync/Commands/" + _myId;
|
||||||
|
|
||||||
handleStateChange(result);
|
handleStateChange(result);
|
||||||
|
|
||||||
|
@ -355,7 +368,8 @@ void HeartbeatThread::runCoordinator() {
|
||||||
TRI_UseCoordinatorDatabaseServer(_server, i->c_str());
|
TRI_UseCoordinatorDatabaseServer(_server, i->c_str());
|
||||||
|
|
||||||
if (vocbase != nullptr) {
|
if (vocbase != nullptr) {
|
||||||
LOG(INFO) << "Reloading users for database " << vocbase->_name
|
LOG_TOPIC(INFO, Logger::HEARTBEAT)
|
||||||
|
<< "Reloading users for database " << vocbase->_name
|
||||||
<< ".";
|
<< ".";
|
||||||
|
|
||||||
if (!fetchUsers(vocbase)) {
|
if (!fetchUsers(vocbase)) {
|
||||||
|
@ -409,7 +423,7 @@ void HeartbeatThread::runCoordinator() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(TRACE) << "stopped heartbeat thread";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT) << "stopped heartbeat thread";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -431,14 +445,16 @@ bool HeartbeatThread::init() {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void HeartbeatThread::removeDispatchedJob(ServerJobResult result) {
|
void HeartbeatThread::removeDispatchedJob(ServerJobResult result) {
|
||||||
LOG(TRACE) << "Dispatched job returned!";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT) << "Dispatched job returned!";
|
||||||
{
|
{
|
||||||
MUTEX_LOCKER(mutexLocker, _statusLock);
|
MUTEX_LOCKER(mutexLocker, _statusLock);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
LOG(DEBUG) << "Sync request successful. Now have Plan " << result.planVersion << ", Current " << result.currentVersion;
|
LOG_TOPIC(DEBUG, Logger::HEARTBEAT)
|
||||||
|
<< "Sync request successful. Now have Plan " << result.planVersion
|
||||||
|
<< ", Current " << result.currentVersion;
|
||||||
_currentVersions = AgencyVersions(result);
|
_currentVersions = AgencyVersions(result);
|
||||||
} else {
|
} else {
|
||||||
LOG(DEBUG) << "Sync request failed!";
|
LOG_TOPIC(DEBUG, Logger::HEARTBEAT) << "Sync request failed!";
|
||||||
// mop: we will retry immediately so wait at least a LITTLE bit
|
// mop: we will retry immediately so wait at least a LITTLE bit
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
}
|
}
|
||||||
|
@ -458,7 +474,7 @@ static std::string const prefixPlanChangeCoordinator = "Plan/Databases";
|
||||||
bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
|
bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
|
||||||
|
|
||||||
bool fetchingUsersFailed = false;
|
bool fetchingUsersFailed = false;
|
||||||
LOG(TRACE) << "found a plan update";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT) << "found a plan update";
|
||||||
AgencyCommResult result;
|
AgencyCommResult result;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -489,7 +505,8 @@ bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
|
||||||
}
|
}
|
||||||
auto nameSlice = options.value.get("name");
|
auto nameSlice = options.value.get("name");
|
||||||
if (nameSlice.isNone()) {
|
if (nameSlice.isNone()) {
|
||||||
LOG (ERR) << "Missing name in agency database plan";
|
LOG_TOPIC(ERR, Logger::HEARTBEAT)
|
||||||
|
<< "Missing name in agency database plan";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,8 +519,9 @@ bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
|
||||||
try {
|
try {
|
||||||
id = std::stoul(v.copyString());
|
id = std::stoul(v.copyString());
|
||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
LOG(ERR) << "Failed to convert id string to number";
|
LOG_TOPIC(ERR, Logger::HEARTBEAT)
|
||||||
LOG(ERR) << e.what();
|
<< "Failed to convert id string to number";
|
||||||
|
LOG_TOPIC(ERR, Logger::HEARTBEAT) << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,7 +597,8 @@ bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
|
||||||
|
|
||||||
// turn on error logging now
|
// turn on error logging now
|
||||||
if (!ClusterComm::instance()->enableConnectionErrorLogging(true)) {
|
if (!ClusterComm::instance()->enableConnectionErrorLogging(true)) {
|
||||||
LOG(INFO) << "created coordinator databases for the first time";
|
LOG_TOPIC(INFO, Logger::HEARTBEAT)
|
||||||
|
<< "created coordinator databases for the first time";
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -603,15 +622,16 @@ bool HeartbeatThread::syncDBServerStatusQuo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_desiredVersions.plan > _currentVersions.plan) {
|
if (_desiredVersions.plan > _currentVersions.plan) {
|
||||||
LOG(DEBUG) << "Plan version " << _currentVersions.plan
|
LOG_TOPIC(DEBUG, Logger::HEARTBEAT)
|
||||||
|
<< "Plan version " << _currentVersions.plan
|
||||||
<< " is lower than desired version " << _desiredVersions.plan;
|
<< " is lower than desired version " << _desiredVersions.plan;
|
||||||
_isDispatchingChange = true;
|
_isDispatchingChange = true;
|
||||||
becauseOfPlan = true;
|
becauseOfPlan = true;
|
||||||
}
|
}
|
||||||
if (_desiredVersions.current > _currentVersions.current) {
|
if (_desiredVersions.current > _currentVersions.current) {
|
||||||
LOG(DEBUG) << "Current version " << _currentVersions.current
|
LOG_TOPIC(DEBUG, Logger::HEARTBEAT)
|
||||||
<< " is lower than desired version "
|
<< "Current version " << _currentVersions.current
|
||||||
<< _desiredVersions.current;
|
<< " is lower than desired version " << _desiredVersions.current;
|
||||||
_isDispatchingChange = true;
|
_isDispatchingChange = true;
|
||||||
becauseOfCurrent = true;
|
becauseOfCurrent = true;
|
||||||
}
|
}
|
||||||
|
@ -628,22 +648,23 @@ bool HeartbeatThread::syncDBServerStatusQuo() {
|
||||||
ci->invalidateCurrent();
|
ci->invalidateCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(TRACE) << "Dispatching Sync";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT) << "Dispatching Sync";
|
||||||
// schedule a job for the change
|
// schedule a job for the change
|
||||||
std::unique_ptr<arangodb::rest::Job> job(new ServerJob(this));
|
std::unique_ptr<arangodb::rest::Job> job(new ServerJob(this));
|
||||||
|
|
||||||
auto dispatcher = DispatcherFeature::DISPATCHER;
|
auto dispatcher = DispatcherFeature::DISPATCHER;
|
||||||
if (dispatcher == nullptr) {
|
if (dispatcher == nullptr) {
|
||||||
LOG(ERR) << "could not schedule dbserver sync - dispatcher gone.";
|
LOG_TOPIC(ERR, Logger::HEARTBEAT)
|
||||||
|
<< "could not schedule dbserver sync - dispatcher gone.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (dispatcher->addJob(job) == TRI_ERROR_NO_ERROR) {
|
if (dispatcher->addJob(job) == TRI_ERROR_NO_ERROR) {
|
||||||
LOG(TRACE) << "scheduled dbserver sync";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT) << "scheduled dbserver sync";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
MUTEX_LOCKER(mutexLocker, _statusLock);
|
MUTEX_LOCKER(mutexLocker, _statusLock);
|
||||||
_isDispatchingChange = false;
|
_isDispatchingChange = false;
|
||||||
LOG(ERR) << "could not schedule dbserver sync";
|
LOG_TOPIC(ERR, Logger::HEARTBEAT) << "could not schedule dbserver sync";
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -690,7 +711,8 @@ bool HeartbeatThread::sendState() {
|
||||||
if (++_numFails % _maxFailsBeforeWarning == 0) {
|
if (++_numFails % _maxFailsBeforeWarning == 0) {
|
||||||
std::string const endpoints = AgencyComm::getEndpointsString();
|
std::string const endpoints = AgencyComm::getEndpointsString();
|
||||||
|
|
||||||
LOG(WARN) << "heartbeat could not be sent to agency endpoints ("
|
LOG_TOPIC(WARN, Logger::HEARTBEAT)
|
||||||
|
<< "heartbeat could not be sent to agency endpoints ("
|
||||||
<< endpoints << "): http code: " << result.httpCode()
|
<< endpoints << "): http code: " << result.httpCode()
|
||||||
<< ", body: " << result.body();
|
<< ", body: " << result.body();
|
||||||
_numFails = 0;
|
_numFails = 0;
|
||||||
|
@ -708,7 +730,8 @@ bool HeartbeatThread::fetchUsers(TRI_vocbase_t* vocbase) {
|
||||||
VPackBuilder builder;
|
VPackBuilder builder;
|
||||||
builder.openArray();
|
builder.openArray();
|
||||||
|
|
||||||
LOG(TRACE) << "fetching users for database '" << vocbase->_name << "'";
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT)
|
||||||
|
<< "fetching users for database '" << vocbase->_name << "'";
|
||||||
|
|
||||||
int res = usersOnCoordinator(std::string(vocbase->_name), builder, 10.0);
|
int res = usersOnCoordinator(std::string(vocbase->_name), builder, 10.0);
|
||||||
|
|
||||||
|
@ -740,11 +763,12 @@ bool HeartbeatThread::fetchUsers(TRI_vocbase_t* vocbase) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
LOG(TRACE) << "fetching users for database '" << vocbase->_name
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT)
|
||||||
<< "' successful";
|
<< "fetching users for database '" << vocbase->_name << "' successful";
|
||||||
_refetchUsers.erase(vocbase);
|
_refetchUsers.erase(vocbase);
|
||||||
} else {
|
} else {
|
||||||
LOG(TRACE) << "fetching users for database '" << vocbase->_name
|
LOG_TOPIC(TRACE, Logger::HEARTBEAT)
|
||||||
|
<< "fetching users for database '" << vocbase->_name
|
||||||
<< "' failed with error: " << TRI_errno_string(res);
|
<< "' failed with error: " << TRI_errno_string(res);
|
||||||
_refetchUsers.insert(vocbase);
|
_refetchUsers.insert(vocbase);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,12 @@ Mutex LogTopic::_namesLock;
|
||||||
std::map<std::string, LogTopic*> LogTopic::_names;
|
std::map<std::string, LogTopic*> LogTopic::_names;
|
||||||
|
|
||||||
LogTopic Logger::AGENCY("agency", LogLevel::INFO);
|
LogTopic Logger::AGENCY("agency", LogLevel::INFO);
|
||||||
|
LogTopic Logger::AGENCYCOMM("agencycomm", LogLevel::INFO);
|
||||||
LogTopic Logger::COLLECTOR("collector");
|
LogTopic Logger::COLLECTOR("collector");
|
||||||
LogTopic Logger::COMPACTOR("compactor");
|
LogTopic Logger::COMPACTOR("compactor");
|
||||||
LogTopic Logger::CONFIG("config");
|
LogTopic Logger::CONFIG("config");
|
||||||
LogTopic Logger::DATAFILES("datafiles", LogLevel::INFO);
|
LogTopic Logger::DATAFILES("datafiles", LogLevel::INFO);
|
||||||
|
LogTopic Logger::HEARTBEAT("heartbeat", LogLevel::INFO);
|
||||||
LogTopic Logger::MMAP("mmap");
|
LogTopic Logger::MMAP("mmap");
|
||||||
LogTopic Logger::PERFORMANCE("performance", LogLevel::FATAL); // suppress
|
LogTopic Logger::PERFORMANCE("performance", LogLevel::FATAL); // suppress
|
||||||
LogTopic Logger::QUERIES("queries", LogLevel::INFO);
|
LogTopic Logger::QUERIES("queries", LogLevel::INFO);
|
||||||
|
|
|
@ -128,10 +128,12 @@ class Logger {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static LogTopic AGENCY;
|
static LogTopic AGENCY;
|
||||||
|
static LogTopic AGENCYCOMM;
|
||||||
static LogTopic COLLECTOR;
|
static LogTopic COLLECTOR;
|
||||||
static LogTopic COMPACTOR;
|
static LogTopic COMPACTOR;
|
||||||
static LogTopic CONFIG;
|
static LogTopic CONFIG;
|
||||||
static LogTopic DATAFILES;
|
static LogTopic DATAFILES;
|
||||||
|
static LogTopic HEARTBEAT;
|
||||||
static LogTopic MMAP;
|
static LogTopic MMAP;
|
||||||
static LogTopic PERFORMANCE;
|
static LogTopic PERFORMANCE;
|
||||||
static LogTopic QUERIES;
|
static LogTopic QUERIES;
|
||||||
|
|
Loading…
Reference in New Issue