summaryrefslogtreecommitdiff
path: root/src/t_stream.c
diff options
context:
space:
mode:
authorguybe7 <guy.benoish@redislabs.com>2022-10-24 17:27:56 +0200
committerGitHub <noreply@github.com>2022-10-24 18:27:56 +0300
commit737a090511f0aacc53d9b9f91a8f30106a1d7464 (patch)
treec14c10697a598243d85d9643ff7839610b13ba13 /src/t_stream.c
parentbd23b15ad7281d9e59aaba4afa5120f9c55bb1a9 (diff)
downloadredis-737a090511f0aacc53d9b9f91a8f30106a1d7464.tar.gz
Set errno in case XADD with partial ID fails (#11424)
This is a rare failure mode of a new feature of redis 7 introduced in #9217 (when the incremental part of the ID overflows). Till now, the outcome of that error was undetermined (could easily result in `Elements are too large to be stored` wrongly, due to unset `errno`).
Diffstat (limited to 'src/t_stream.c')
-rw-r--r--src/t_stream.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/t_stream.c b/src/t_stream.c
index 5d06529d7..85ae4354b 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -437,6 +437,7 @@ int streamAppendItem(stream *s, robj **argv, int64_t numfields, streamID *added_
* in time. */
if (s->last_id.ms == use_id->ms) {
if (s->last_id.seq == UINT64_MAX) {
+ errno = EDOM;
return C_ERR;
}
id = s->last_id;
@@ -2025,10 +2026,12 @@ void xaddCommand(client *c) {
}
/* Append using the low level function and return the ID. */
+ errno = 0;
streamID id;
if (streamAppendItem(s,c->argv+field_pos,(c->argc-field_pos)/2,
&id,parsed_args.id_given ? &parsed_args.id : NULL,parsed_args.seq_given) == C_ERR)
{
+ serverAssert(errno != 0);
if (errno == EDOM)
addReplyError(c,"The ID specified in XADD is equal or smaller than "
"the target stream top item");