In XADD take deleted items into consideration when switch to new node (#8390)

If we set stream-node-max-bytes = 0, then we insert entry then delete,
do this many times, the last stream node will be very big.
This commit is contained in:
Huang Zw 2021-02-22 21:08:16 +08:00 committed by GitHub
parent f5235b2d76
commit b164c4dec3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -512,7 +512,9 @@ int streamAppendItem(stream *s, robj **argv, int64_t numfields, streamID *added_
{
lp = NULL;
} else if (server.stream_node_max_entries) {
int64_t count = lpGetInteger(lpFirst(lp));
unsigned char *lp_ele = lpFirst(lp);
/* Count both live entries and deleted ones. */
int64_t count = lpGetInteger(lp_ele) + lpGetInteger(lpNext(lp,lp_ele));
if (count >= server.stream_node_max_entries) {
/* Shrink extra pre-allocated memory */
lp = lpShrinkToFit(lp);