1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-15 17:51:06 +00:00

chore: zset error log (from 1.18 branch) (#3109)

This commit is contained in:
Vladislav 2024-05-31 16:00:09 +03:00 committed by GitHub
parent 0394387a5f
commit b3ca27068a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 3 deletions

View file

@ -357,8 +357,18 @@ OpResult<string> RunCbOnFirstNonEmptyBlocking(Transaction* trans, int req_obj_ty
return OpStatus::OK; return OpStatus::OK;
}; };
trans->Execute(std::move(cb), true); trans->Execute(std::move(cb), true);
if (info) if (info) {
*info = "BLOCK/"; *info = "BLOCK/";
for (unsigned sid = 0; sid < shard_set->size(); sid++) {
if (!trans->IsActive(sid))
continue;
if (auto wake_key = trans->GetWakeKey(sid); wake_key)
*info += absl::StrCat("sid:", sid, ",key:", *wake_key, ",");
}
*info += "/";
*info += trans->DEBUGV18_BlockInfo();
*info += "/";
}
return result_key; return result_key;
} }

View file

@ -363,6 +363,13 @@ class Transaction {
return shard_data_[SidToId(sid)].local_mask; return shard_data_[SidToId(sid)].local_mask;
} }
// Remove once BZPOP is stabilized
std::string DEBUGV18_BlockInfo() {
return "claimed=" + std::to_string(blocking_barrier_.IsClaimed()) +
" coord_state=" + std::to_string(int(coordinator_state_)) +
" local_res=" + std::to_string(int(local_result_));
}
private: private:
// Holds number of locks for each IntentLock::Mode: shared and exlusive. // Holds number of locks for each IntentLock::Mode: shared and exlusive.
struct LockCnt { struct LockCnt {

View file

@ -1325,7 +1325,7 @@ void BZPopMinMax(CmdArgList args, ConnectionContext* cntx, bool is_max) {
Transaction* transaction = cntx->transaction; Transaction* transaction = cntx->transaction;
std::string dinfo; std::string dinfo;
std::string callback_ran_key = "/NONE/"; optional<std::string> callback_ran_key;
OpResult<ScoredArray> popped_array; OpResult<ScoredArray> popped_array;
auto cb = [is_max, &popped_array, &callback_ran_key](Transaction* t, EngineShard* shard, auto cb = [is_max, &popped_array, &callback_ran_key](Transaction* t, EngineShard* shard,
std::string_view key) { std::string_view key) {
@ -1339,10 +1339,15 @@ void BZPopMinMax(CmdArgList args, ConnectionContext* cntx, bool is_max) {
auto* rb = static_cast<RedisReplyBuilder*>(cntx->reply_builder()); auto* rb = static_cast<RedisReplyBuilder*>(cntx->reply_builder());
if (popped_key) { if (popped_key) {
if (!callback_ran_key) {
LOG(ERROR) << "BUG: Callback didn't run! " << popped_key.value() << " " << dinfo;
return rb->SendNullArray();
}
DVLOG(1) << "BZPop " << transaction->DebugId() << " popped from key " << popped_key; // key. DVLOG(1) << "BZPop " << transaction->DebugId() << " popped from key " << popped_key; // key.
CHECK(popped_array.ok()) << dinfo; CHECK(popped_array.ok()) << dinfo;
CHECK_EQ(popped_array->size(), 1u) CHECK_EQ(popped_array->size(), 1u)
<< popped_key << " ran " << callback_ran_key << " info " << dinfo; << popped_key << " ran " << *callback_ran_key << " info " << dinfo;
rb->StartArray(3); rb->StartArray(3);
rb->SendBulkString(*popped_key); rb->SendBulkString(*popped_key);
rb->SendBulkString(popped_array->front().first); rb->SendBulkString(popped_array->front().first);