188 Commits

Author SHA1 Message Date
Guy Benoish
2ad427f862 ld2string should fail if string contains \0 in the middle
This bug affected RM_StringToLongDouble and HINCRBYFLOAT.
I added tests for both cases.

Main changes:
1. Fixed string2ld to fail if string contains \0 in the middle
2. Use string2ld in getLongDoubleFromObject - No point of
   having duplicated code here

The two changes above broke RM_SaveLongDouble/RM_LoadLongDouble
because the long double string was saved with length+1 (An innocent
mistake, but it's actually a bug - The length passed to
RM_SaveLongDouble should not include the last \0).
2020-02-04 10:23:48 +01:00
Guy Benoish
3913ffd5bc Blocking XREAD[GROUP] should always reply with valid data (or timeout)
This commit solves the following bug:
127.0.0.1:6379> XGROUP CREATE x grp $ MKSTREAM
OK
127.0.0.1:6379> XADD x 666 f v
"666-0"
127.0.0.1:6379> XREADGROUP GROUP grp Alice BLOCK 0 STREAMS x >
1) 1) "x"
   2) 1) 1) "666-0"
         2) 1) "f"
            2) "v"
127.0.0.1:6379> XADD x 667 f v
"667-0"
127.0.0.1:6379> XDEL x 667
(integer) 1
127.0.0.1:6379> XREADGROUP GROUP grp Alice BLOCK 0 STREAMS x >
1) 1) "x"
   2) (empty array)

The root cause is that we use s->last_id in streamCompareID
while we should use the last *valid* ID
2020-01-10 13:16:14 +01:00
Guy Benoish
444dd1075c Stream: Handle streamID-related edge cases
This commit solves several edge cases that are related to
exhausting the streamID limits: We should correctly calculate
the succeeding streamID instead of blindly incrementing 'seq'
This affects both XREAD and XADD.

Other (unrelated) changes:
Reply with a better error message when trying to add an entry
to a stream that has exhausted last_id
2019-12-29 15:46:31 +01:00
antirez
fa60228c08 Fix stream test after addition of 0-0 ID test. 2019-11-19 11:49:05 +01:00
Guy Benoish
181ae55753 XADD with ID 0-0 stores an empty key
Calling XADD with 0-0 or 0 would result in creating an
empty key and storing it in the database.
Even worse, because XADD will reply with error the action
will not be replicated, creating a master-replica
inconsistency
2019-11-13 16:47:30 +05:30
Loris Cro
61d46950dc fix unreported overflow in autogerenared stream IDs 2019-11-04 16:36:06 +01:00
antirez
0ec3cbdb8d Test: fix implementation-dependent test after code change. 2019-10-10 15:22:42 +02:00
Salvatore Sanfilippo
cb44f7ece0 Merge pull request #5907 from spjwebster/xclaim-increment-delivery-count
Increment delivery counter on XCLAIM unless RETRYCOUNT specified
2019-03-13 11:55:46 +01:00
Steve Webster
c652f706cb Only increment delivery count if JUSTID option is omitted 2019-03-12 20:27:53 +00:00
Salvatore Sanfilippo
685d10894b Merge pull request #2774 from rouzier/blocking-list-commands-support-milliseconds-floating
Added millisecond resolution for blpop command && friends
2019-03-12 18:10:28 +01:00
Steve Webster
8fd63c220a Increment delivery counter on XCLAIM unless RETRYCOUNT specified
The XCLAIM docs state the XCLAIM increments the delivery counter for
messages. This PR makes the code match the documentation - which seems
like the desired behaviour - whilst still allowing RETRYCOUNT to be
specified manually.

My understanding of the way streamPropagateXCLAIM() works is that this
change will safely propagate to replicas since retry count is pulled
directly from the streamNACK struct.

Fixes #5194
2019-03-08 17:09:11 +00:00
Salvatore Sanfilippo
0423081513 Merge pull request #5549 from oranagra/fix_test_races
fix small test suite race conditions
2018-11-28 18:17:05 +01:00
antirez
5f4be1f85c Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-11-28 17:12:32 +01:00
Qu Chen
36af9ebbd4 Add unit test for stream XCLAIM command. 2018-11-28 17:12:03 +01:00
Salvatore Sanfilippo
390e02f2c9 Merge pull request #4737 from guybe7/zlexcount_fix
Don't call sdscmp() with shared.maxstring or shared.minstring
2018-11-28 16:53:32 +01:00
antirez
068e49c65a Test: regression test for #5570. 2018-11-19 17:19:33 +01:00
antirez
562588cf29 Test: regression test for #5577. 2018-11-19 16:50:54 +01:00
Oran Agra
05d6b8b9ae fix small test suite race conditions 2018-11-12 10:26:10 +02:00
antirez
de887c7e1d Tests for XGROUP CREATE MKSTREAM. 2018-10-17 12:11:10 +02:00
zhaozhao.zz
340e1b8c96 Streams: Tests modified XSTREAM -> XSETID 2018-10-16 23:56:26 +08:00
antirez
f501a8367c Tests modified to use XADD MAXLEN 0 + XSETID.
See #5426.
2018-10-16 17:28:56 +02:00
Salvatore Sanfilippo
ff1b36c825 Merge pull request #5426 from soloestoy/feature-xstream
Bugfix data inconsistency after aof rewrite, and add XSTREAM command.
2018-10-16 13:10:36 +02:00
antirez
b43c423a81 Test: cgroup propagation test also for NOACK variant.
Related to #5433.
2018-10-10 17:37:41 +02:00
antirez
d2fa12b96a Test: consumer group last ID slave propagation test.
This is a regression for #5433.
2018-10-10 17:32:17 +02:00
zhaozhao.zz
ed72c0fd84 Streams: add tests for aof rewrite 2018-10-09 15:45:58 +08:00
zhaozhao.zz
4ef06caf6e Streams: add tests for XSTREAM command 2018-10-09 15:21:08 +08:00
Salvatore Sanfilippo
06219d42d9 Merge pull request #5141 from soloestoy/fix-xtrim-inconsistency
Fix XTRIM and XADD with MAXLEN inconsistency
2018-10-08 12:00:00 +02:00
antirez
d86f233cf3 Test: new sorted set skiplist order consistency.
This should be able to find new bugs and regressions about the new
sorted set update function when ZADD is used to update an element
already existing.

The test is able to find the bug fixed at 156f26d0 immediately.
2018-08-02 14:15:53 +02:00
zhaozhao.zz
d7dc6851ff Streams: add test cases for XADD/XTRIM maxlen 2018-08-01 10:34:29 +08:00
antirez
b01cb491a8 Test: XDEL fuzz testing. Remove and check stage. 2018-07-13 17:58:17 +02:00
antirez
6ddca524c4 Test: XDEL fuzz testing, stream creation. 2018-07-13 17:47:26 +02:00
antirez
9b799a052d Test: XDEL basic test. 2018-07-13 17:40:48 +02:00
antirez
fadce22ae9 Add regression test for #5111. 2018-07-12 13:35:17 +02:00
Jack Drogon
bae1d36e5d Fix typo 2018-07-03 18:19:46 +02:00
antirez
e937fff4ab Regression test for issue #5006. 2018-06-12 13:13:35 +02:00
antirez
2c08c2d425 ZPOP: invert score-ele to match ZRANGE WITHSCORES order. 2018-06-05 17:06:25 +02:00
antirez
5b69ad6e6d Streams: fix test ID format. 2018-05-25 16:57:08 +02:00
antirez
d0326f472e ZPOP: fix the tests according to new non-blocking "count" argument. 2018-05-11 18:07:10 +02:00
antirez
cbbeef707e ZPOP: renaming to have explicit MIN/MAX score idea.
This commit also adds a top comment about a subtle behavior of mixing
blocking operations of different types in the same key.
2018-05-11 17:31:53 +02:00
Itamar Haber
52c9565dda Implements [B]Z[REV]POP and the respective unit tests
An implementation of the
[Ze POP Redis Module](https://github.com/itamarhaber/zpop) as core
Redis commands.

Fixes #1861.
2018-04-30 02:10:42 +03:00
antirez
72282c440b CG: test XACK remaining features. 2018-03-15 12:54:10 +01:00
antirez
c72389ef0f CG: test XACK ability to remove items from the PELs. 2018-03-15 12:54:10 +01:00
antirez
862c29fc1b CG: test XPENDING ability to return pending items. 2018-03-15 12:54:10 +01:00
antirez
0a5272cea8 CG: test XGROUPREAD abilities. 2018-03-15 12:54:10 +01:00
antirez
8d3c0e4186 CG: More specific duplicated group error. 2018-03-15 12:54:10 +01:00
Guy Benoish
1d9705a424 Don't call sdscmp() with shared.maxstring or shared.minstring 2018-03-06 20:14:35 +07:00
antirez
b404a1717f Streams: add some initial test for XREVRANGE. 2017-12-01 10:24:25 +01:00
antirez
0e6b2095ec Streams: fix XREAD test broken after previous tests improvements.
10% of times the data is not just "item 0" but there is also the
"otherfield" part. Use [lrange] to avoid the issue.
This commit fixes #4416.
2017-12-01 10:24:24 +01:00
antirez
6808443d33 Streams: move ID ms/seq separator from '.' to '-'
After checking with the community via Twitter (here:
https://twitter.com/antirez/status/915130876861788161) the verdict was to
use ":". However I later realized, after users lamented the fact that
it's hard to copy IDs just with double click, that this was the reason
why I moved to "." in the first instance. Fortunately "-", that was the
other option with most votes, also gets selected with double click on
most terminal applications on Linux and MacOS.

So my reasoning was:

1) We can't retain "." because it's actually confusing to newcomers, it
looks like a floating number, people may be tricked into thinking they
can order IDs numerically as floats.

2) Moving to a double-click-to-select format is much better. People will
work with such IDs for long time when coding / debugging. Why making now
a choice that will impact this for the next years?

The only other viable option was "-", and that's what I did. Thanks.
2017-12-01 10:24:24 +01:00
antirez
b9184aea54 Streams: add XADD + MAXLEN test. 2017-12-01 10:24:24 +01:00