mirror of https://gitee.com/bigwinds/arangodb
Bug fix 3.3/integer overflow when calculating waits in constituent (#4090)
* integer overflow in Constituent could seize operation of Agency * less likely integer overflow on double conversion * less likely integer overflow on double conversion * changed comparison to integer comparison as suggested by @neunhoef
This commit is contained in:
parent
90e6c78845
commit
b7ee607312
|
@ -819,7 +819,7 @@ AgencyCommResult AgencyComm::setValue(std::string const& key,
|
|||
|
||||
AgencyOperation operation(key, AgencyValueOperationType::SET,
|
||||
builder.slice());
|
||||
operation._ttl = static_cast<uint32_t>(ttl);
|
||||
operation._ttl = static_cast<uint64_t>(ttl);
|
||||
AgencyWriteTransaction transaction(operation);
|
||||
|
||||
return sendTransactionWithFailover(transaction);
|
||||
|
@ -829,7 +829,7 @@ AgencyCommResult AgencyComm::setValue(std::string const& key,
|
|||
arangodb::velocypack::Slice const& slice,
|
||||
double ttl) {
|
||||
AgencyOperation operation(key, AgencyValueOperationType::SET, slice);
|
||||
operation._ttl = static_cast<uint32_t>(ttl);
|
||||
operation._ttl = static_cast<uint64_t>(ttl);
|
||||
AgencyWriteTransaction transaction(operation);
|
||||
|
||||
return sendTransactionWithFailover(transaction);
|
||||
|
@ -839,7 +839,7 @@ AgencyCommResult AgencyComm::setTransient(std::string const& key,
|
|||
arangodb::velocypack::Slice const& slice,
|
||||
double ttl) {
|
||||
AgencyOperation operation(key, AgencyValueOperationType::SET, slice);
|
||||
operation._ttl = static_cast<uint32_t>(ttl);
|
||||
operation._ttl = static_cast<uint64_t>(ttl);
|
||||
AgencyTransientTransaction transaction(operation);
|
||||
|
||||
return sendTransactionWithFailover(transaction);
|
||||
|
@ -938,7 +938,7 @@ AgencyCommResult AgencyComm::casValue(std::string const& key,
|
|||
AgencyPrecondition precondition(key, AgencyPrecondition::Type::EMPTY,
|
||||
!prevExist);
|
||||
if (ttl >= 0.0) {
|
||||
operation._ttl = static_cast<uint32_t>(ttl);
|
||||
operation._ttl = static_cast<uint64_t>(ttl);
|
||||
}
|
||||
|
||||
VPackBuilder preBuilder;
|
||||
|
@ -963,7 +963,7 @@ AgencyCommResult AgencyComm::casValue(std::string const& key,
|
|||
AgencyPrecondition precondition(key, AgencyPrecondition::Type::VALUE,
|
||||
oldBuilder.slice());
|
||||
if (ttl >= 0.0) {
|
||||
operation._ttl = static_cast<uint32_t>(ttl);
|
||||
operation._ttl = static_cast<uint64_t>(ttl);
|
||||
}
|
||||
|
||||
AgencyWriteTransaction transaction(operation, precondition);
|
||||
|
|
|
@ -204,7 +204,7 @@ class AgencyOperation {
|
|||
AgencyOperationType type() const;
|
||||
|
||||
public:
|
||||
uint32_t _ttl = 0;
|
||||
uint64_t _ttl = 0;
|
||||
VPackSlice _oldValue;
|
||||
|
||||
private:
|
||||
|
|
|
@ -702,7 +702,7 @@ void Constituent::run() {
|
|||
LOG_TOPIC(TRACE, Logger::AGENCY)
|
||||
<< "Random timeout: " << randTimeout << ", wait: " << randWait;
|
||||
|
||||
if (randWait > 0.0) {
|
||||
if (randWait > 0) {
|
||||
CONDITION_LOCKER(guardv, _cv);
|
||||
_cv.wait(randWait);
|
||||
}
|
||||
|
@ -719,7 +719,7 @@ void Constituent::run() {
|
|||
double diff = TRI_microtime() - _lastHeartbeatSeen;
|
||||
LOG_TOPIC(TRACE, Logger::AGENCY) << "last heartbeat: " << diff << "sec ago";
|
||||
|
||||
isTimeout = (static_cast<int32_t>(M * diff) > randTimeout);
|
||||
isTimeout = (static_cast<int64_t>(M * diff) > randTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue