From 7d823644b3d84fd0632e0d43ba4c61e4c39630c4 Mon Sep 17 00:00:00 2001 From: DaeMyung Kang Date: Sun, 19 Apr 2026 23:10:22 +0900 Subject: [PATCH] hash: pause auto-shrink during HGETDEL Match HGETDEL with the existing batch-delete pattern used by HDEL. HDEL already pauses hashtable auto-shrink while deleting multiple fields so shrink evaluation is deferred until the batch completes. HGETDEL was missing the same optimization even though it also deletes fields in a loop. Pause auto-shrink for hashtable-encoded hashes before the HGETDEL delete loop and resume it once afterwards. This preserves observable behavior and reduces redundant shrink work for multi-field deletes. Signed-off-by: DaeMyung Kang --- src/t_hash.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/t_hash.c b/src/t_hash.c index eecac218c8b..7f94f3e45bc 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -1173,6 +1173,7 @@ void hgetdelCommand(client *c) { if (checkType(c, o, OBJ_HASH)) return; bool hash_volatile_items = hashTypeHasVolatileFields(o); + if (o && o->encoding == OBJ_ENCODING_HASHTABLE) hashtablePauseAutoShrink(objectGetVal(o)); /* Reply with array of values and delete at the same time */ addReplyArrayLen(c, num_fields); @@ -1191,6 +1192,7 @@ void hgetdelCommand(client *c) { } } } + if (!keyremoved && o && o->encoding == OBJ_ENCODING_HASHTABLE) hashtableResumeAutoShrink(objectGetVal(o)); if (deleted) { if (!keyremoved && hash_volatile_items != hashTypeHasVolatileFields(o)) {