Skip to content

Commit

Permalink
Specify timeouts when timing out (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shillaker committed Sep 10, 2021
1 parent 68bdb05 commit 76ac9b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/redis/Redis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,11 @@ redisReply* Redis::dequeueBase(const std::string& queueName, int timeoutMs)

// Check if we got anything
if (reply == nullptr || reply->type == REDIS_REPLY_NIL) {
throw RedisNoResponseException(
"No response from Redis dequeue for queue " + queueName);
std::string msg =
fmt::format("No response from Redis dequeue in {}ms for queue {}",
timeoutMs,
queueName);
throw RedisNoResponseException(msg);
}

// Should get an array when doing a blpop, check it.
Expand Down Expand Up @@ -737,8 +740,8 @@ std::vector<uint8_t> Redis::dequeueBytes(const std::string& queueName,

std::vector<uint8_t> replyBytes;
if (isBlocking) {
// BLPOP will return the queue name and the value returned (elements 0
// and 1)
// BLPOP will return the queue name and the value returned (elements
// 0 and 1)
redisReply* r = reply->element[1];
replyBytes = getBytesFromReply(r);
} else {
Expand Down Expand Up @@ -794,5 +797,4 @@ void Redis::publishSchedulerResult(const std::string& key,
STATUS_KEY_EXPIRY);
extractScriptResult(reply);
}

}
3 changes: 3 additions & 0 deletions src/util/barrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ void Barrier::wait()
if (!cv.wait_until(lock, timePoint, [this, phaseCompletionVisits] {
return visits >= phaseCompletionVisits;
})) {
std::string msg =
fmt::format("Barrier timed out ({}ms)", timeoutMs);
SPDLOG_ERROR(msg);
throw std::runtime_error("Barrier timed out");
}
}
Expand Down

0 comments on commit 76ac9b2

Please sign in to comment.