From cfffc434552abde91e1cd9425e33f06d3bb5285e Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Tue, 22 Nov 2016 13:25:31 +0100 Subject: [PATCH 1/7] add possibility to force static openssl linking --- Installation/Jenkins/build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Installation/Jenkins/build.sh b/Installation/Jenkins/build.sh index 13ff88d0ad..7404facca4 100755 --- a/Installation/Jenkins/build.sh +++ b/Installation/Jenkins/build.sh @@ -339,6 +339,12 @@ while [ $# -gt 0 ]; do CONFIGURE_OPTIONS="${CONFIGURE_OPTIONS} -DRPM_DISTRO=$1" shift ;; + + --staticOpenSSL) + shift + CONFIGURE_OPTIONS="${CONFIGURE_OPTIONS} -DOPENSSL_USE_STATIC_LIBS=TRUE" + shift + ;; --enterprise) From 8686b4eadbff99575051a94941d0f3c76e874698 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Tue, 22 Nov 2016 13:27:17 +0100 Subject: [PATCH 2/7] add possibility to force static openssl linking --- Installation/Jenkins/build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/Installation/Jenkins/build.sh b/Installation/Jenkins/build.sh index 7404facca4..aa1ea6de67 100755 --- a/Installation/Jenkins/build.sh +++ b/Installation/Jenkins/build.sh @@ -343,7 +343,6 @@ while [ $# -gt 0 ]; do --staticOpenSSL) shift CONFIGURE_OPTIONS="${CONFIGURE_OPTIONS} -DOPENSSL_USE_STATIC_LIBS=TRUE" - shift ;; From a854cbf674e3b02c75b06699481e3cd1baec5fdc Mon Sep 17 00:00:00 2001 From: Alan Plum Date: Tue, 22 Nov 2016 13:59:16 +0100 Subject: [PATCH 3/7] Fix Windows file path resolution --- js/server/modules/@arangodb/actions.js | 2 +- js/server/modules/@arangodb/foxx/legacy/swagger.js | 4 ++-- js/server/modules/@arangodb/foxx/swagger.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/js/server/modules/@arangodb/actions.js b/js/server/modules/@arangodb/actions.js index f4a8c85ce0..3d46f57a61 100644 --- a/js/server/modules/@arangodb/actions.js +++ b/js/server/modules/@arangodb/actions.js @@ -2018,7 +2018,7 @@ function pathHandler (req, res, options, next) { 'use strict'; var filepath, root, filename, encodedFilename; - filepath = req.suffix.length ? path.resolve(path.sep, ...req.suffix.map((part) => decodeURIComponent(part))) : ''; + filepath = req.suffix.length ? path.normalize(['', ...req.suffix.map((part) => decodeURIComponent(part))].join(path.sep)) : ''; root = options.path; if (options.root) { diff --git a/js/server/modules/@arangodb/foxx/legacy/swagger.js b/js/server/modules/@arangodb/foxx/legacy/swagger.js index 848ed5d2d3..672c6a9c62 100644 --- a/js/server/modules/@arangodb/foxx/legacy/swagger.js +++ b/js/server/modules/@arangodb/foxx/legacy/swagger.js @@ -25,7 +25,7 @@ var _ = require('lodash'); var fs = require('fs'); var joinPath = require('path').join; -var resolvePath = require('path').resolve; +var normalizePath = require('path').normalize; var internal = require('internal'); var ArangoError = require('@arangodb').ArangoError; var errors = require('@arangodb').errors; @@ -97,7 +97,7 @@ function swaggerPath (path, basePath) { if (!basePath) { basePath = joinPath(internal.startupPath, 'server', 'assets', 'swagger'); } - path = resolvePath('/', path); + path = normalizePath('/' + path); return joinPath(basePath, path); } diff --git a/js/server/modules/@arangodb/foxx/swagger.js b/js/server/modules/@arangodb/foxx/swagger.js index 4fcadc7042..2781eff907 100644 --- a/js/server/modules/@arangodb/foxx/swagger.js +++ b/js/server/modules/@arangodb/foxx/swagger.js @@ -25,7 +25,7 @@ const NotFound = require('http-errors').NotFound; const fs = require('fs'); const joinPath = require('path').join; -const resolvePath = require('path').resolve; +const normalizePath = require('path').normalize; const internal = require('internal'); const errors = require('@arangodb').errors; const FoxxManager = require('@arangodb/foxx/manager'); @@ -102,7 +102,7 @@ module.exports = function createSwaggerRouteHandler (foxxMount, opts) { } else if (path === 'index.html') { path = indexFile; } - path = resolvePath('/', path); + path = normalizePath('/' + path); const filePath = joinPath(swaggerRoot, path); if (!fs.isFile(filePath)) { throw new NotFound(`unknown path "${req._raw.url}"`); From 63a173f002d9aeda065393fbb41f3b84bb6e6781 Mon Sep 17 00:00:00 2001 From: Andreas Streichardt Date: Tue, 22 Nov 2016 14:12:38 +0100 Subject: [PATCH 4/7] Delete all shard move jobs when server is healthy again --- arangod/Agency/FailedServer.cpp | 40 +++++++++++++++++++++++++++++---- arangod/Agency/Job.h | 1 + arangod/Agency/Supervision.h | 3 ++- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/arangod/Agency/FailedServer.cpp b/arangod/Agency/FailedServer.cpp index d149ba82b6..5a71b48573 100644 --- a/arangod/Agency/FailedServer.cpp +++ b/arangod/Agency/FailedServer.cpp @@ -230,23 +230,55 @@ JOB_STATUS FailedServer::status() { } if (status == PENDING) { + auto const& serverHealth = _snapshot(healthPrefix + _server + "/Status").getString(); + + // mop: ohhh...server is healthy again! + bool serverHealthy = serverHealth == Supervision::HEALTH_STATUS_GOOD; + + std::shared_ptr deleteTodos; + Node::Children const todos = _snapshot(toDoPrefix).children(); Node::Children const pends = _snapshot(pendingPrefix).children(); - size_t found = 0; + bool hasOpenChildTasks = false; for (auto const& subJob : todos) { if (!subJob.first.compare(0, _jobId.size() + 1, _jobId + "-")) { - found++; + if (serverHealthy) { + if (!deleteTodos) { + deleteTodos.reset(new Builder()); + deleteTodos->openArray(); + deleteTodos->openObject(); + } + deleteTodos->add(_agencyPrefix + toDoPrefix + subJob.first, VPackValue(VPackValueType::Object)); + deleteTodos->add("op", VPackValue("delete")); + deleteTodos->close(); + } else { + hasOpenChildTasks = true; + } } } for (auto const& subJob : pends) { if (!subJob.first.compare(0, _jobId.size() + 1, _jobId + "-")) { - found++; + hasOpenChildTasks = true; } } - if (!found) { + if (deleteTodos) { + LOG_TOPIC(INFO, Logger::AGENCY) << "Server " << _server << " is healthy again. Will try to delete any jobs which have not yet started!"; + deleteTodos->close(); + deleteTodos->close(); + // Transact to agency + write_ret_t res = transact(_agent, *deleteTodos); + + if (!res.accepted || res.indices.size() != 1 || !res.indices[0]) { + LOG_TOPIC(WARN, Logger::AGENCY) + << "Server was healthy. Tried deleting subjobs but failed :("; + return status; + } + } + + if (!hasOpenChildTasks) { if (finish("DBServers/" + _server)) { return FINISHED; } diff --git a/arangod/Agency/Job.h b/arangod/Agency/Job.h index c4be8c3aaa..087321f43f 100644 --- a/arangod/Agency/Job.h +++ b/arangod/Agency/Job.h @@ -54,6 +54,7 @@ static std::string const blockedShardsPrefix = "/Supervision/Shards/"; static std::string const serverStatePrefix = "/Sync/ServerStates/"; static std::string const planVersion = "/Plan/Version"; static std::string const plannedServers = "/Plan/DBServers"; +static std::string const healthPrefix = "/Supervision/Health/"; inline arangodb::consensus::write_ret_t transact(Agent* _agent, Builder const& transaction, diff --git a/arangod/Agency/Supervision.h b/arangod/Agency/Supervision.h index 0c9d266732..7449ca4f96 100644 --- a/arangod/Agency/Supervision.h +++ b/arangod/Agency/Supervision.h @@ -111,11 +111,12 @@ class Supervision : public arangodb::Thread { /// @brief Upgrade agency void upgradeAgency(); - private: static constexpr const char* HEALTH_STATUS_GOOD = "GOOD"; static constexpr const char* HEALTH_STATUS_BAD = "BAD"; static constexpr const char* HEALTH_STATUS_FAILED = "FAILED"; + private: + /// @brief Update agency prefix from agency itself bool updateAgencyPrefix(size_t nTries = 10, int intervalSec = 1); From c1db7228c7ced2bbf200dbcebd13cedd82259c92 Mon Sep 17 00:00:00 2001 From: Andreas Streichardt Date: Tue, 22 Nov 2016 15:07:00 +0100 Subject: [PATCH 5/7] Coordinator will not always wait for system collection replication --- js/server/bootstrap/coordinator.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/js/server/bootstrap/coordinator.js b/js/server/bootstrap/coordinator.js index 57d8f39000..5ace44dd9f 100644 --- a/js/server/bootstrap/coordinator.js +++ b/js/server/bootstrap/coordinator.js @@ -50,12 +50,19 @@ } if (internal.threadNumber === 0) { - // Wait for synchronous replication of system colls to settle: - console.info('Waiting for synchronous replication of system collections...'); - var db = internal.db; - var colls = db._collections(); - colls = colls.filter(c => c.name()[0] === '_'); - require('@arangodb/cluster').waitForSyncRepl('_system', colls); + var systemCollectionsCreated = global.ArangoAgency.get('SystemCollectionsCreated'); + if (!(systemCollectionsCreated && systemCollectionsCreated.arango && systemCollectionsCreated.arango.SystemCollectionsCreated)) { + // Wait for synchronous replication of system colls to settle: + console.info('Waiting for initial replication of system collections...'); + var db = internal.db; + var colls = db._collections(); + colls = colls.filter(c => c.name()[0] === '_'); + if (!require('@arangodb/cluster').waitForSyncRepl('_system', colls)) { + console.error('System collections not properly set up. Starting anyway now...'); + } else { + global.ArangoAgency.set('SystemCollectionsCreated', true); + } + } } if (internal.threadNumber === 0) { From c8e23a7faaa2f24b143020a8ae467fae30ae1781 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Tue, 22 Nov 2016 16:18:29 +0100 Subject: [PATCH 6/7] probably older cmakes don't like strequal that way --- cmake/packages/rpm.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/packages/rpm.cmake b/cmake/packages/rpm.cmake index b3329dc49b..d64077777d 100644 --- a/cmake/packages/rpm.cmake +++ b/cmake/packages/rpm.cmake @@ -10,9 +10,9 @@ set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_BINARY_DIR}/arangodb.spec") ################################################################################ # deploy the Init script: -if (${RPM_DISTRO} STREQUAL "SUSE13") +if (RPM_DISTRO STREQUAL "SUSE13") set(RPM_INIT_SCRIPT "${PROJECT_SOURCE_DIR}/Installation/rpm/rc.arangod.OpenSuSE_13") -elseif (${RPM_DISTRO} STREQUAL "SUSE") +elseif (RPM_DISTRO STREQUAL "SUSE") set(RPM_INIT_SCRIPT "${PROJECT_SOURCE_DIR}/Installation/rpm/rc.arangod.OpenSuSE") else () # fall back to centos: set(RPM_INIT_SCRIPT "${PROJECT_SOURCE_DIR}/Installation/rpm/rc.arangod.Centos") From 1f29e2de810bef10ae3872b6c5db190ded4bbfa3 Mon Sep 17 00:00:00 2001 From: Jan Christoph Uhde Date: Tue, 22 Nov 2016 16:18:39 +0100 Subject: [PATCH 7/7] better log facilities for debugging statistics --- arangod/Statistics/statistics.cpp | 53 +++++++++++++++++++++++++++++++ arangod/Statistics/statistics.h | 23 ++------------ 2 files changed, 55 insertions(+), 21 deletions(-) diff --git a/arangod/Statistics/statistics.cpp b/arangod/Statistics/statistics.cpp index 3b5424fc7b..a343b2a955 100644 --- a/arangod/Statistics/statistics.cpp +++ b/arangod/Statistics/statistics.cpp @@ -40,6 +40,59 @@ thread_local TRI_request_statistics_t* TRI_request_statistics_t::STATS = static size_t const QUEUE_SIZE = 1000; +std::string TRI_request_statistics_t::to_string(){ + std::stringstream ss; + ss << std::boolalpha << std::setprecision(20) << "statistics " + << std::endl + << "_readStart " << _readStart << std::endl + << "_readEnd " << _readEnd << std::endl + << "_queueStart " << _queueStart << std::endl + << "_queueEnd " << _queueEnd << std::endl + << "_requestStart " << _requestStart << std::endl + << "_requestEnd " << _requestEnd << std::endl + << "_writeStart " << _writeStart << std::endl + << "_writeEnd " << _writeEnd << std::endl + << "_receivedBytes " << _receivedBytes << std::endl + << "_sentBytes " << _sentBytes << std::endl + << "_async " << _async << std::endl + << "_tooLarge " << _tooLarge << std::endl + << "_executeError " << _executeError << std::endl + << "_ignore " << _ignore << std::endl; + + return ss.str(); +} + +void TRI_request_statistics_t::trace_log(){ + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_readStart " << _readStart; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_readEnd " << _readEnd; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_queueStart " << _queueStart; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_queueEnd " << _queueEnd; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_requestStart " << _requestStart; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_requestEnd " << _requestEnd; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_writeStart " << _writeStart; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_writeEnd " << _writeEnd; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_receivedBytes " << _receivedBytes; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_sentBytes " << _sentBytes; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_async " << _async; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_tooLarge " << _tooLarge; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_executeError " << _executeError; + LOG_TOPIC(TRACE, Logger::REQUESTS) << std::boolalpha << std::setprecision(20) + << "_ignore " << _ignore; +} + //////////////////////////////////////////////////////////////////////////////// /// @brief lock for request statistics data //////////////////////////////////////////////////////////////////////////////// diff --git a/arangod/Statistics/statistics.h b/arangod/Statistics/statistics.h index 40923a0493..0571c621e8 100644 --- a/arangod/Statistics/statistics.h +++ b/arangod/Statistics/statistics.h @@ -80,27 +80,8 @@ struct TRI_request_statistics_t { #endif } - std::string to_string() { - std::stringstream ss; - ss << std::boolalpha << std::setprecision(20) << "statistics " - << std::endl - << "_readStart " << _readStart << std::endl - << "_readEnd " << _readEnd << std::endl - << "_queueStart " << _queueStart << std::endl - << "_queueEnd " << _queueEnd << std::endl - << "_requestStart " << _requestStart << std::endl - << "_requestEnd " << _requestEnd << std::endl - << "_writeStart " << _writeStart << std::endl - << "_writeEnd " << _writeEnd << std::endl - << "_receivedBytes " << _receivedBytes << std::endl - << "_sentBytes " << _sentBytes << std::endl - << "_async " << _async << std::endl - << "_tooLarge " << _tooLarge << std::endl - << "_executeError " << _executeError << std::endl - << "_ignore " << _ignore << std::endl; - - return ss.str(); - } + std::string to_string(); + void trace_log(); double _readStart; // CommTask::processRead - read first byte of message double _readEnd; // CommTask::processRead - message complete