57 Commits

Author SHA1 Message Date
antirez
c4becaebaa Modules: block on keys: implement the internals. 2019-10-30 10:57:44 +01:00
antirez
c98af3a550 handleClientsBlockedOnKeys() refactoring. 2019-09-06 12:24:26 +02:00
antirez
3984b4fdd9 Fix handleClientsBlockedOnKeys() names in comments. 2019-09-05 13:05:57 +02: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
antirez
4dcae43dba RESP3: t_stream.c updated. 2019-01-09 17:00:29 +01:00
antirez
f47004f589 RESP3: restore the concept of null array for RESP2 compat. 2019-01-09 17:00:29 +01:00
antirez
380191c2a9 RESP3: blocked.c updated. 2019-01-09 17:00:29 +01:00
antirez
7591c476f8 Slave removal: blocked.c logs fixed. 2018-09-11 15:32:28 +02:00
antirez
02306736c9 Unblocked clients API refactoring. See #4418. 2018-09-03 18:39:18 +02:00
antirez
f0348a6543 Make pending buffer processing safe for CLIENT_MASTER client.
Related to #5305.
2018-09-03 18:17:31 +02:00
zhaozhao.zz
88d8b45fbe block: format code 2018-08-14 20:59:32 +08:00
dejun.xdj
0496480b12 Streams: using streamCompareID() instead of direct compare in block.c. 2018-07-14 15:03:05 +08:00
antirez
c55bce5022 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-07-10 12:06:44 +02:00
antirez
8576a47263 Streams: fix typo "consumer". 2018-07-10 12:04:31 +02:00
antirez
aeb04948e2 Streams: send an error to consumers blocked on non-existing group.
To detect when the group (or the whole key) is destroyed to send an
error to the consumers blocked in such group is a problem, so we leave
the consumers listening, the sysadmin is free to create or destroy
groups assuming she/he knows what to do. However a client may be blocked
in a given consumer group, that is later destroyed. Then the stream
receives new elements. In that case there is no sane behavior to serve
the consumer... but to report an error about the group no longer
existing.

More about detecting this synchronously and why it is not done:

1. Normally we don't do that, we leave clients blocked for other data
types such as lists.

2. When we free a stream object there is no longer information about
what was the key it was associated with, so while destroying the
consumer groups we miss the info to unblock the clients in that moment.

3. Objects can be reclaimed in other threads where it is no longer safe
to do client operations.
2018-07-10 11:19:06 +02:00
antirez
7035bcd48a Streams: fix unblocking logic into a consumer group.
When a client blocks for a consumer group, we don't know the actual ID
we want to be served: other clients blocked in the same consumer group
may be served first, so the consumer group latest delivered ID changes.
This was not handled correctly, all the clients in the consumer group
were unblocked without data but the first.
2018-07-10 11:11:41 +02:00
dejun.xdj
07ef48956d Bugfix: PEL is incorrect when consumer is blocked using xreadgroup with NOACK option.
Save NOACK option into client.blockingState structure.
2018-07-09 13:40:29 +02:00
antirez
8824c84b67 Fix client unblocking for XREADGROUP, issue #4978.
We unblocked the client too early, when the group name object was no
longer valid in client->bpop, so propagating XCLAIM later in
streamPropagateXCLAIM() deferenced a field already set to NULL.
2018-06-11 16:51:06 +02:00
zhaozhao.zz
4e16144569 ZPOP: unblock multiple clients in right way 2018-05-31 23:35:47 +08:00
antirez
0d5689cc83 ZPOP: fix replication of blocking ZPOP. 2018-05-15 16:03:56 +02:00
antirez
7cc0d0875b ZPOP: change sync ZPOP to have a count argument instead of N keys.
Usually blocking operations make a lot of sense with multiple keys so
that we can listen to multiple queues (or whatever the app models) with
a single connection. However in the synchronous case it is more useful
to be able to ask for N elements. This is a change that I also wanted to
perform soon or later in the blocking list variant, but here it is more
natural since there is no reply type difference.
2018-05-11 18:00:32 +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
Salvatore Sanfilippo
de08dd52df Merge pull request #4781 from guybe7/block_list_notify
Make blocking list commands send keyspace notifications
2018-03-22 16:21:19 +01:00
Guy Benoish
d4340f5689 Make blocking list commands send keyspace notifications 2018-03-22 17:22:26 +07:00
antirez
d7fa510612 CG: Replication WIP 1: XREADGROUP and XCLAIM propagated as XCLAIM. 2018-03-19 18:02:19 +01:00
antirez
922b74828b CG: XPENDING should not create consumers and obey to count. 2018-03-15 12:54:10 +01:00
antirez
f49cbaf84c CG: Now XREADGROUP + blocking operations work. 2018-03-15 12:54:10 +01:00
antirez
840ad8cec6 CG: creation of NACK entries in PELs. 2018-03-15 12:54:10 +01:00
antirez
0f43a908f9 CG: consumer lookup + initial streamReplyWithRange() work to supprot CG. 2018-03-15 12:54:10 +01:00
antirez
23dc98ac52 CG: add & populate group+consumer in the blocking state. 2018-03-15 12:54:10 +01:00
antirez
009c14e944 Streams: state machine for reverse iteration WIP 1. 2017-12-01 10:24:25 +01:00
antirez
065257d83a Streams: fixed memory leaks when blocking again for same stream.
blockForKeys() was not freeing the allocation holding the ID when the
key was already found busy. Fortunately the unit test checked explicitly
for blocking multiple times for the same key (copying a regression in
the blocking lists tests), so the bug was detected by the Redis test leak
checker.
2017-12-01 10:24:24 +01:00
antirez
2f2a810b52 Streams: fix handleClientsBlockedOnKeys() access to invalid ID. 2017-12-01 10:24:24 +01:00
antirez
799eaab940 Streams: fix XREAD ready-key signaling.
With lists we need to signal only on key creation, but streams can
provide data to clients listening at every new item added.
To make this slightly more efficient we now track different classes of
blocked clients to avoid signaling keys when there is nobody listening.
A typical case is when the stream is used as a time series DB and
accessed only by range with XRANGE.
2017-12-01 10:24:24 +01:00
antirez
3aa11e22a4 Streams: XREAD related code to serve blocked clients. 2017-12-01 10:24:24 +01:00
antirez
9290ad3cb9 Streams: XREAD ability to block fixed. 2017-12-01 10:24:24 +01:00
antirez
a477b95b01 Streams: augment client.bpop with XREAD specific fields. 2017-12-01 10:24:24 +01:00
antirez
53600c7fd5 Streams: more internal preparation for blocking XREAD. 2017-12-01 10:24:24 +01:00
antirez
f6179c38b0 Streams: initial work to use blocking lists logic for streams XREAD. 2017-12-01 10:24:24 +01:00
antirez
2ae6258ba7 Module: API to block clients with threading support.
Just a draft to align the main ideas, never executed code. Compiles.
2016-10-07 11:55:35 +02:00
James Rouzier
9ebde01b73 If the unit of a timeout is seconds treat it a float 2016-02-23 12:05:29 -05:00
antirez
c15cac0d77 RDMF: More consistent define names. 2015-07-27 14:37:58 +02:00
antirez
8a893fa4cf RDMF: REDIS_OK REDIS_ERR -> C_OK C_ERR. 2015-07-26 23:17:55 +02:00
antirez
58844a7bfe RDMF: redisAssert -> serverAssert. 2015-07-26 15:29:53 +02:00
antirez
fa26d3dd63 RDMF: use client instead of redisClient, like Disque. 2015-07-26 15:20:52 +02:00
antirez
6a424b5e36 RDMF (Redis/Disque merge friendlyness) refactoring WIP 1. 2015-07-26 15:17:18 +02:00
antirez
eac4f0b19f Substitute DISQUE to REDIS after merge from Disque
Probably this stuff should be called CLIENT_* in order to cross merge
more easily.
2015-05-05 16:36:35 +02:00
antirez
8648703210 processUnblockedClients: don't process clients that blocekd again 2015-05-05 16:35:44 +02:00
antirez
8218790448 Don't put clients into unblocked list multiple times 2015-05-05 16:32:53 +02:00