summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2018-07-17 23:57:42 +0800
committerzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2018-08-01 10:31:27 +0800
commit20c6a7fe2c134ad21bfc4ce50e548c3a055e93d0 (patch)
treebe55fb21f44f78bbbd690e8bd64eb9863883a188
parent2f2987ffc5c3cbf8eab307782a07f20492a3d439 (diff)
downloadredis-20c6a7fe2c134ad21bfc4ce50e548c3a055e93d0.tar.gz
Streams: propagate original MAXLEN argument in XADD context
If we rewrite the MAXLEN argument as zero when no trimming was performed, date between master and slave and aof will be inconsistent, because `xtrim maxlen 0` means delete all entries in stream.
-rw-r--r--src/t_stream.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/t_stream.c b/src/t_stream.c
index 72d03b466..5814aa132 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -1186,18 +1186,9 @@ void xaddCommand(client *c) {
notifyKeyspaceEvent(NOTIFY_STREAM,"xadd",c->argv[1],c->db->id);
server.dirty++;
- /* Remove older elements if MAXLEN was specified. */
- if (maxlen >= 0) {
- if (!streamTrimByLength(s,maxlen,approx_maxlen)) {
- /* If no trimming was performed, for instance because approximated
- * trimming length was specified, rewrite the MAXLEN argument
- * as zero, so that the command is propagated without trimming. */
- robj *zeroobj = createStringObjectFromLongLong(0);
- rewriteClientCommandArgument(c,maxlen_arg_idx,zeroobj);
- decrRefCount(zeroobj);
- } else {
- notifyKeyspaceEvent(NOTIFY_STREAM,"xtrim",c->argv[1],c->db->id);
- }
+ /* Notify xtrim event if needed. */
+ if (maxlen >= 0 && streamTrimByLength(s,maxlen,approx_maxlen)) {
+ notifyKeyspaceEvent(NOTIFY_STREAM,"xtrim",c->argv[1],c->db->id);
}
/* Let's rewrite the ID argument with the one actually generated for