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
  • Loading branch information
uriyage committed Jul 9, 2024
1 parent 0e5b387 commit 9b06940
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -2398,6 +2398,8 @@ int handleClientsWithPendingWrites(void) {
listIter li;
listNode *ln;
listRewind(server.clients_pending_write, &li);
/* Don't try to send to I/O threads if we are OOM as we want to free the clients' COB as soon as possible. */
int try_send_to_io_threads = server.active_io_threads_num > 1 && !(server.maxmemory > 0 && zmalloc_used_memory() > server.maxmemory);
while ((ln = listNext(&li))) {
client *c = listNodeValue(ln);
c->flag.pending_write = 0;
Expand All @@ -2413,8 +2415,7 @@ int handleClientsWithPendingWrites(void) {
if (!clientHasPendingReplies(c)) continue;

/* If we can send the client to the I/O thread, let it handle the write. */
// int oom = server.maxmemory > 0 && zmalloc_used_memory() > server.maxmemory;
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 9b06940

Please sign in to comment.