Skip to content

Commit

Permalink
Do not send pending writes to I/O threads while OOM
Browse files Browse the repository at this point in the history
Signed-off-by: Uri Yagelnik <[email protected]>
  • Loading branch information
uriyage committed Jul 11, 2024
1 parent 548b4e0 commit 0986964
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -2397,6 +2397,8 @@ int handleClientsWithPendingWrites(void) {
listIter li;
listNode *ln;
listRewind(server.clients_pending_write, &li);
/* Avoid sending to I/O threads during out-of-memory conditions to free clients' COBs as quickly as possible */
int try_send_to_io_threads = server.active_io_threads_num > 1 && getMaxmemoryState(NULL, NULL, NULL, NULL) == C_OK;
while ((ln = listNext(&li))) {
client *c = listNodeValue(ln);
c->flag.pending_write = 0;
Expand All @@ -2412,7 +2414,7 @@ int handleClientsWithPendingWrites(void) {
if (!clientHasPendingReplies(c)) continue;

/* If we can send the client to the I/O thread, let it handle the write. */
if (trySendWriteToIOThreads(c) == C_OK) continue;
if (try_send_to_io_threads && trySendWriteToIOThreads(c) == C_OK) continue;

/* We can't write to the client while IO operation is in progress. */
if (c->io_write_state != CLIENT_IDLE || c->io_read_state != CLIENT_IDLE) continue;
Expand Down

0 comments on commit 0986964

Please sign in to comment.