Preallocate enough memory for the stream node if elements exceed stream_node_max_bytes

This commit is contained in:
sundb 2023-03-09 17:20:44 +08:00
parent 9d336ac398
commit 534b4f1cec

View file

@ -563,6 +563,7 @@ int streamAppendItem(stream *s, robj **argv, int64_t numfields, streamID *added_
if (server.stream_node_max_bytes > 0 && server.stream_node_max_bytes < prealloc) {
prealloc = server.stream_node_max_bytes;
}
if (prealloc < totelelen) prealloc = totelelen;
lp = lpNew(prealloc);
lp = lpAppendInteger(lp,1); /* One item, the one we are adding. */
lp = lpAppendInteger(lp,0); /* Zero deleted so far. */