Skip to content

Commit f632395

Browse files
not asserting on wrong condition on rate-limiting
1 parent 06c6d1e commit f632395

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

memtier_benchmark.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,8 +1568,8 @@ run_stats run_benchmark(int run_id, benchmark_config* cfg, object_generator* obj
15681568
unsigned long int total_connection_errors = 0;
15691569

15701570
for (std::vector<cg_thread*>::iterator i = threads.begin(); i != threads.end(); i++) {
1571-
// Check if thread needs restart
1572-
if ((*i)->m_finished && (*i)->m_restart_requested && (*i)->m_restart_count < 5) {
1571+
// Check if thread needs restart (but only if shutdown is not requested)
1572+
if (!g_shutdown_requested && (*i)->m_finished && (*i)->m_restart_requested && (*i)->m_restart_count < 5) {
15731573
benchmark_error_log("Restarting thread %u (restart #%u)...\n",
15741574
(*i)->m_thread_id, (*i)->m_restart_count + 1);
15751575

shard_connection.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ void shard_connection::disconnect() {
367367

368368
m_connection_state = conn_disconnected;
369369

370+
// Reset rate limiting state during disconnection
371+
m_request_per_cur_interval = 0;
372+
370373
// by default no need to send any setup request
371374
m_authentication = setup_done;
372375
m_db_selection = setup_done;
@@ -421,8 +424,13 @@ void shard_connection::push_req(request* req) {
421424
m_pipeline->push(req);
422425
m_pending_resp++;
423426
if (m_config->request_rate) {
424-
assert(m_request_per_cur_interval > 0);
425-
m_request_per_cur_interval--;
427+
// Handle race condition during reconnection - don't assert if interval is 0
428+
if (m_request_per_cur_interval > 0) {
429+
m_request_per_cur_interval--;
430+
} else {
431+
// Rate limit exceeded, but don't crash - just log debug info
432+
benchmark_debug_log("Rate limit interval exhausted during request push (connection %u)\n", m_id);
433+
}
426434
}
427435
}
428436

0 commit comments

Comments
 (0)