- 02 Dec, 2012 1 commit
-
-
antirez authored
Sending a command like: BLPOP foo foo foo foo 0 Resulted into a crash before this commit since the client ended being inserted in the waiting list for this key multiple times. This resulted into the function handleClientsBlockedOnLists() to fail because we have code like that: if (de) { list *clients = dictGetVal(de); int numclients = listLength(clients); while(numclients--) { listNode *clientnode = listFirst(clients); /* server clients here... */ } } The code to serve clients used to remove the served client from the waiting list, so if a client is blocking multiple times, eventually the call to listFirst() will return NULL or worse will access random memory since the list may no longer exist as it is removed by the function unblockClientWaitingData() if there are no more clients waiting for this list. To avoid making the rest of the implementation more complex, this commit modifies blockForKeys() so that a client will be put just a single time into the waiting list for a given key. Since it is Saturday, I hope this fixes issue #801.
-
- 08 Nov, 2012 1 commit
-
-
antirez authored
-
- 17 Sep, 2012 1 commit
-
-
antirez authored
Redis provides support for blocking operations such as BLPOP or BRPOP. This operations are identical to normal LPOP and RPOP operations as long as there are elements in the target list, but if the list is empty they block waiting for new data to arrive to the list. All the clients blocked waiting for th same list are served in a FIFO way, so the first that blocked is the first to be served when there is more data pushed by another client into the list. The previous implementation of blocking operations was conceived to serve clients in the context of push operations. For for instance: 1) There is a client "A" blocked on list "foo". 2) The client "B" performs `LPUSH foo somevalue`. 3) The client "A" is served in the context of the "B" LPUSH, synchronously. Processing things in a synchronous way was useful as if "A" pushes a value that is served by "B", from the point of view of the database is a NOP (no operation) thing, that is, nothing is replicated, nothing is written in the AOF file, and so forth. However later we implemented two things: 1) Variadic LPUSH that could add multiple values to a list in the context of a single call. 2) BRPOPLPUSH that was a version of BRPOP that also provided a "PUSH" side effect when receiving data. This forced us to make the synchronous implementation more complex. If client "B" is waiting for data, and "A" pushes three elemnents in a single call, we needed to propagate an LPUSH with a missing argument in the AOF and replication link. We also needed to make sure to replicate the LPUSH side of BRPOPLPUSH, but only if in turn did not happened to serve another blocking client into another list ;) This were complex but with a few of mutually recursive functions everything worked as expected... until one day we introduced scripting in Redis. Scripting + synchronous blocking operations = Issue #614. Basically you can't "rewrite" a script to have just a partial effect on the replicas and AOF file if the script happened to serve a few blocked clients. The solution to all this problems, implemented by this commit, is to change the way we serve blocked clients. Instead of serving the blocked clients synchronously, in the context of the command performing the PUSH operation, it is now an asynchronous and iterative process: 1) If a key that has clients blocked waiting for data is the subject of a list push operation, We simply mark keys as "ready" and put it into a queue. 2) Every command pushing stuff on lists, as a variadic LPUSH, a script, or whatever it is, is replicated verbatim without any rewriting. 3) Every time a Redis command, a MULTI/EXEC block, or a script, completed its execution, we run the list of keys ready to serve blocked clients (as more data arrived), and process this list serving the blocked clients. 4) As a result of "3" maybe more keys are ready again for other clients (as a result of BRPOPLPUSH we may have push operations), so we iterate back to step "3" if it's needed. The new code has a much simpler semantics, and a simpler to understand implementation, with the disadvantage of not being able to "optmize out" a PUSH+BPOP as a No OP. This commit will be tested with care before the final merge, more tests will be added likely.
-
- 18 Apr, 2012 1 commit
-
-
antirez authored
-
- 27 Mar, 2012 1 commit
-
-
Premysl Hruby authored
-
- 29 Feb, 2012 2 commits
- 28 Feb, 2012 2 commits
- 31 Jan, 2012 1 commit
-
-
antirez authored
-
- 19 Dec, 2011 1 commit
-
-
BigCat authored
Using `getLongFromObjectOrReply` instead of `atoi` if possible. The following functions are modified. * lrangeCommand * ltrimCommand * lremCommand * lindexCommand * lsetCommand * zunionInterGenericCommand * genericZrangebyscoreCommand * sortCommand
-
- 08 Nov, 2011 1 commit
-
-
antirez authored
-
- 04 Oct, 2011 1 commit
-
-
antirez authored
-
- 14 Sep, 2011 1 commit
-
-
antirez authored
Optimize LRANGE to scan the list starting from the head or the tail in order to traverse the minimal number of elements. Thanks to Didier Spezia for noticing the problem and providing a patch.
-
- 12 Sep, 2011 1 commit
-
-
antirez authored
-
- 07 Sep, 2011 1 commit
-
-
Hampus Wessman authored
-
- 08 Jul, 2011 1 commit
-
-
antirez authored
Take a pointer to the relevant entry of the command table in the client structure. This is generally a more sounding design, simplifies a few functions prototype, and as a side effect fixes a bug related to the conversion of EXPIRE -1 to DEL: before of this fix Redis tried to convert it into an EXPIREAT in the AOF code, regardless of our rewrite of the command.
-
- 20 Jun, 2011 1 commit
-
-
antirez authored
-
- 11 May, 2011 1 commit
-
-
antirez authored
removed assert causing an illegal memory access. This was responsible of crashes during BLPOP and other list blocking operations.
-
- 15 Apr, 2011 1 commit
-
-
antirez authored
-
- 03 Feb, 2011 2 commits
-
-
Pieter Noordhuis authored
-
Pieter Noordhuis authored
-
- 17 Jan, 2011 1 commit
-
-
Pieter Noordhuis authored
-
- 29 Dec, 2010 1 commit
-
-
antirez authored
touched key for WATCH refactored into a more general thing that can be used also for the cache system. Some more changes towards diskstore working.
-
- 07 Dec, 2010 1 commit
-
-
antirez authored
LRANGE converted into a COW friendly command. Some refactoring, comment, and new addReply*() family function added in the process.
-
- 06 Dec, 2010 6 commits
-
-
Pieter Noordhuis authored
-
Pieter Noordhuis authored
-
Pieter Noordhuis authored
-
Pieter Noordhuis authored
-
Pieter Noordhuis authored
-
Pieter Noordhuis authored
-
- 30 Nov, 2010 9 commits
-
-
Michel Martens & Damian Janowski authored
-
Damian Janowski & Michel Martens authored
-
Damian Janowski & Michel Martens authored
-
Damian Janowski & Michel Martens authored
-
Damian Janowski & Michel Martens authored
-
Damian Janowski & Michel Martens authored
-
Damian Janowski & Michel Martens authored
-
Damian Janowski & Michel Martens authored
-
Damian Janowski & Michel Martens authored
-