fix: fix interpreter acquisition with MULTI (#2549)

* fix: fix interpreter acquisition with MULTI

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
Vladislav 2024-02-06 13:54:14 +03:00 committed by GitHub
parent bc9b214ae4
commit 83a12b99c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 114 additions and 34 deletions

View file

@ -48,7 +48,7 @@ auto ServerState::Stats::operator=(Stats&& other) -> Stats& {
}
ServerState::Stats& ServerState::Stats::Add(unsigned num_shards, const ServerState::Stats& other) {
static_assert(sizeof(Stats) == 12 * 8, "Stats size mismatch");
static_assert(sizeof(Stats) == 13 * 8, "Stats size mismatch");
for (int i = 0; i < NUM_TX_TYPES; ++i) {
this->tx_type_cnt[i] += other.tx_type_cnt[i];
@ -63,6 +63,8 @@ ServerState::Stats& ServerState::Stats::Add(unsigned num_shards, const ServerSta
this->multi_squash_exec_hop_usec += other.multi_squash_exec_hop_usec;
this->multi_squash_exec_reply_usec += other.multi_squash_exec_reply_usec;
this->blocked_on_interpreter += other.blocked_on_interpreter;
if (this->tx_width_freq_arr == nullptr) {
this->tx_width_freq_arr = new uint64_t[num_shards];
std::copy_n(other.tx_width_freq_arr, num_shards, this->tx_width_freq_arr);
@ -174,7 +176,10 @@ bool ServerState::IsPaused() const {
}
Interpreter* ServerState::BorrowInterpreter() {
return interpreter_mgr_.Get();
stats.blocked_on_interpreter++;
auto* ptr = interpreter_mgr_.Get();
stats.blocked_on_interpreter--;
return ptr;
}
void ServerState::ReturnInterpreter(Interpreter* ir) {