1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into devel

This commit is contained in:
Kaveh Vahedipour 2017-01-24 12:52:35 +01:00
commit 3a034f5817
8 changed files with 39 additions and 65 deletions

View File

@ -139,6 +139,8 @@ std::string Node::uri() const {
/// Move constructor /// Move constructor
Node::Node(Node&& other) Node::Node(Node&& other)
: _node_name(std::move(other._node_name)), : _node_name(std::move(other._node_name)),
_parent(nullptr),
_store(nullptr),
_children(std::move(other._children)), _children(std::move(other._children)),
_value(std::move(other._value)), _value(std::move(other._value)),
_vecBuf(std::move(other._vecBuf)), _vecBuf(std::move(other._vecBuf)),

View File

@ -2360,14 +2360,10 @@ void ClusterInfo::loadCurrentDBServers() {
std::vector<ServerID> ClusterInfo::getCurrentDBServers() { std::vector<ServerID> ClusterInfo::getCurrentDBServers() {
std::vector<ServerID> result; std::vector<ServerID> result;
int tries = 0;
if (!_DBServersProt.isValid) { if (!_DBServersProt.isValid) {
loadCurrentDBServers(); loadCurrentDBServers();
tries++;
} }
while (true) {
{
// return a consistent state of servers // return a consistent state of servers
READ_LOCKER(readLocker, _DBServersProt.lock); READ_LOCKER(readLocker, _DBServersProt.lock);
@ -2380,18 +2376,6 @@ std::vector<ServerID> ClusterInfo::getCurrentDBServers() {
return result; return result;
} }
if (++tries >= 2) {
break;
}
// loadCurrentDBServers needs the write lock
loadCurrentDBServers();
}
// note that the result will be empty if we get here
return result;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief find the servers who are responsible for a shard (one leader /// @brief find the servers who are responsible for a shard (one leader
/// and multiple followers) /// and multiple followers)
@ -2560,14 +2544,11 @@ int ClusterInfo::getResponsibleShard(LogicalCollection* collInfo,
std::vector<ServerID> ClusterInfo::getCurrentCoordinators() { std::vector<ServerID> ClusterInfo::getCurrentCoordinators() {
std::vector<ServerID> result; std::vector<ServerID> result;
int tries = 0;
if (!_coordinatorsProt.isValid) { if (!_coordinatorsProt.isValid) {
loadCurrentCoordinators(); loadCurrentCoordinators();
tries++;
} }
while (true) {
{
// return a consistent state of servers // return a consistent state of servers
READ_LOCKER(readLocker, _coordinatorsProt.lock); READ_LOCKER(readLocker, _coordinatorsProt.lock);
@ -2580,18 +2561,6 @@ std::vector<ServerID> ClusterInfo::getCurrentCoordinators() {
return result; return result;
} }
if (++tries >= 2) {
break;
}
// loadCurrentCoordinators needs the write lock
loadCurrentCoordinators();
}
// note that the result will be empty if we get here
return result;
}
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @brief invalidate plan /// @brief invalidate plan
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////

View File

@ -186,8 +186,7 @@ class CollectionInfoCurrent {
bool getFlag(char const* name, ShardID const& shardID) const { bool getFlag(char const* name, ShardID const& shardID) const {
auto it = _vpacks.find(shardID); auto it = _vpacks.find(shardID);
if (it != _vpacks.end()) { if (it != _vpacks.end()) {
return arangodb::basics::VelocyPackHelper::getBooleanValue(it->second->slice(), "errorMessage", return arangodb::basics::VelocyPackHelper::getBooleanValue(it->second->slice(), name, false);
"");
} }
return false; return false;
} }

View File

@ -488,11 +488,12 @@ void MMFilesWalSlots::getActiveTickRange(wal::Logfile* logfile, TRI_voc_tick_t&
/// @brief close a logfile /// @brief close a logfile
int MMFilesWalSlots::closeLogfile(MMFilesWalSlot::TickType& lastCommittedTick, bool& worked) { int MMFilesWalSlots::closeLogfile(MMFilesWalSlot::TickType& lastCommittedTick, bool& worked) {
int iterations = 0;
bool hasWaited = false; bool hasWaited = false;
worked = false; worked = false;
while (++iterations < 1000) { double const maxWait = 30.0;
double const end = TRI_microtime() + maxWait;
while (true) {
{ {
MUTEX_LOCKER(mutexLocker, _lock); MUTEX_LOCKER(mutexLocker, _lock);
@ -593,6 +594,11 @@ int MMFilesWalSlots::closeLogfile(MMFilesWalSlot::TickType& lastCommittedTick, b
if (mustWait) { if (mustWait) {
guard.wait(10 * 1000); guard.wait(10 * 1000);
} }
if (TRI_microtime() >= end) {
// time's up!
break;
}
} }
return TRI_ERROR_ARANGO_NO_JOURNAL; return TRI_ERROR_ARANGO_NO_JOURNAL;

View File

@ -175,6 +175,9 @@ void LogfileManager::collectOptions(std::shared_ptr<ProgramOptions> options) {
"continue recovery even if re-applying operations fails", "continue recovery even if re-applying operations fails",
new BooleanParameter(&_ignoreRecoveryErrors)); new BooleanParameter(&_ignoreRecoveryErrors));
options->addHiddenOption("--wal.flush-timeout", "flush timeout (in milliseconds)",
new UInt64Parameter(&_flushTimeout));
options->addOption("--wal.logfile-size", "size of each logfile (in bytes)", options->addOption("--wal.logfile-size", "size of each logfile (in bytes)",
new UInt32Parameter(&_filesize)); new UInt32Parameter(&_filesize));
@ -1319,7 +1322,7 @@ int LogfileManager::getWriteableLogfile(uint32_t size,
} }
size_t iterations = 0; size_t iterations = 0;
double const end = TRI_microtime() + 15.0; double const end = TRI_microtime() + (_flushTimeout / 1000.0);
while (true) { while (true) {
{ {
@ -1383,7 +1386,7 @@ int LogfileManager::getWriteableLogfile(uint32_t size,
} }
TRI_ASSERT(result == nullptr); TRI_ASSERT(result == nullptr);
LOG(ERR) << "unable to acquire writeable WAL logfile after 15 s"; LOG(ERR) << "unable to acquire writeable WAL logfile after " << _flushTimeout << " ms";
return TRI_ERROR_LOCK_TIMEOUT; return TRI_ERROR_LOCK_TIMEOUT;
} }

View File

@ -465,6 +465,7 @@ class LogfileManager final : public application_features::ApplicationFeature {
uint32_t _historicLogfiles = 10; uint32_t _historicLogfiles = 10;
bool _ignoreLogfileErrors = false; bool _ignoreLogfileErrors = false;
bool _ignoreRecoveryErrors = false; bool _ignoreRecoveryErrors = false;
uint64_t _flushTimeout = 15000;
uint32_t _filesize = 32 * 1024 * 1024; uint32_t _filesize = 32 * 1024 * 1024;
uint32_t _maxOpenLogfiles = 0; uint32_t _maxOpenLogfiles = 0;
uint32_t _reserveLogfiles = 3; uint32_t _reserveLogfiles = 3;

View File

@ -444,7 +444,7 @@ struct hash<arangodb::basics::VPackHashedSlice> {
template <> template <>
struct equal_to<arangodb::basics::VPackHashedSlice> { struct equal_to<arangodb::basics::VPackHashedSlice> {
bool operator()(arangodb::basics::VPackHashedSlice const& lhs, bool operator()(arangodb::basics::VPackHashedSlice const& lhs,
arangodb::basics::VPackHashedSlice const& rhs) const noexcept { arangodb::basics::VPackHashedSlice const& rhs) const {
return lhs.slice.equals(rhs.slice); return lhs.slice.equals(rhs.slice);
} }
}; };

View File

@ -42,8 +42,8 @@ namespace options {
template <typename T> template <typename T>
inline typename std::enable_if<std::is_signed<T>::value, T>::type toNumber( inline typename std::enable_if<std::is_signed<T>::value, T>::type toNumber(
std::string const& value) { std::string const& value) {
auto v = static_cast<T>(std::stoll(value)); auto v = static_cast<int64_t>(std::stoll(value));
if (v < (std::numeric_limits<T>::min)() || v > (std::numeric_limits<T>::max)()) { if (v < static_cast<int64_t>((std::numeric_limits<T>::min)()) || v > static_cast<int64_t>((std::numeric_limits<T>::max)())) {
throw std::out_of_range(value); throw std::out_of_range(value);
} }
return static_cast<T>(v); return static_cast<T>(v);
@ -53,8 +53,8 @@ inline typename std::enable_if<std::is_signed<T>::value, T>::type toNumber(
template <typename T> template <typename T>
inline typename std::enable_if<std::is_unsigned<T>::value, T>::type toNumber( inline typename std::enable_if<std::is_unsigned<T>::value, T>::type toNumber(
std::string const& value) { std::string const& value) {
auto v = static_cast<T>(std::stoull(value)); auto v = static_cast<uint64_t>(std::stoull(value));
if (v < (std::numeric_limits<T>::min)() || v > (std::numeric_limits<T>::max)()) { if (v < static_cast<uint64_t>((std::numeric_limits<T>::min)()) || v > static_cast<uint64_t>((std::numeric_limits<T>::max)())) {
throw std::out_of_range(value); throw std::out_of_range(value);
} }
return static_cast<T>(v); return static_cast<T>(v);
@ -210,15 +210,11 @@ struct NumericParameter : public Parameter {
std::string set(std::string const& value) override { std::string set(std::string const& value) override {
try { try {
ValueType v = toNumber<ValueType>(value); ValueType v = toNumber<ValueType>(value);
if (v >= (std::numeric_limits<T>::min)() &&
v <= (std::numeric_limits<T>::max)()) {
*ptr = v; *ptr = v;
return ""; return "";
}
} catch (...) { } catch (...) {
return "invalid numeric value"; return "invalid numeric value";
} }
return "number out of range";
} }
void toVPack(VPackBuilder& builder) const override { void toVPack(VPackBuilder& builder) const override {
@ -291,9 +287,7 @@ struct BoundedParameter : public T {
std::string set(std::string const& value) override { std::string set(std::string const& value) override {
try { try {
typename T::ValueType v = toNumber<typename T::ValueType>(value); typename T::ValueType v = toNumber<typename T::ValueType>(value);
if (v >= (std::numeric_limits<typename T::ValueType>::min)() && if (v >= minValue && v <= maxValue) {
v <= (std::numeric_limits<typename T::ValueType>::max)() && v >= minValue &&
v <= maxValue) {
*this->ptr = v; *this->ptr = v;
return ""; return "";
} }