Commit Graph

4788 Commits

Author SHA1 Message Date
Salvatore Sanfilippo
66c6218a3c
Merge pull request #4977 from michael-grunder/xpending-early-return
Return early in XPENDING if sent a nonexistent consumer group.
2018-06-07 18:49:09 +02:00
Itamar Haber
c199280edb Globally applies addReplySubSyntaxError 2018-06-07 18:39:36 +03:00
Itamar Haber
76ad23d012 Adds MODULE HELP and implements addReplySubSyntaxError 2018-06-07 18:34:58 +03:00
antirez
a7dbe37d53 Typo: entires -> entries in several places. 2018-06-07 14:36:56 +02:00
antirez
dfb3bf1b1e Streams: make macro node limits configurable. 2018-06-07 14:36:13 +02:00
antirez
6d34ff3645 Streams: max node limits only checked if non zero. 2018-06-07 14:30:25 +02:00
antirez
19a438e2c0 Streams: use non static macro node limits.
Also add the concept of size/items limit, instead of just having as
limit the number of bytes.
2018-06-07 14:24:49 +02:00
shenlongxing
c85ae56edc Fix write() errno error 2018-06-06 13:06:42 +02:00
antirez
b61416bdf4 Fix streamIteratorRemoveEntry() to update elements count.
Close #4989.
2018-06-06 11:40:22 +02:00
antirez
0a698e499a ZPOP: invert score-ele to match ZRANGE WITHSCORES order. 2018-06-05 17:06:25 +02:00
antirez
9e25f3e1de Remove XINFO <key> special form.
As observed by Michael Grunder this usage while practical is
inconsistent because for instance it does not work against a key called
HELP. Removed.
2018-06-05 16:34:34 +02:00
antirez
2f123ea6a3 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-06-04 17:30:11 +02:00
antirez
36b392a0b2 XGROUP SETID implemented + consumer groups core fixes.
Now that we have SETID, the inetrnals of consumer groups should be able
to handle the case of the same message delivered multiple times just
as a side effect of calling XREADGROUP. Normally this should never
happen but if the admin manually "XGROUP SETID mykey mygroup 0",
messages will get re-delivered to clients waiting for the ">" special
ID. The consumer groups internals were not able to handle the case of a
message re-delivered in this circumstances that was already assigned to
another owner.
2018-06-04 17:28:03 +02:00
antirez
05a2996641 Rax library updated. 2018-06-04 17:26:16 +02:00
Salvatore Sanfilippo
b1783d3ab9
Merge pull request #4981 from yossigo/gcc7
Clean gcc 7.x warnings, redis-cli cluster fix.
2018-06-04 17:18:39 +02:00
antirez
7c6f1be5df XGROUP DESTROY implemented. 2018-06-04 12:58:26 +02:00
赵磊
10dedc2586 Fix core dump when using 'command getkeys' with wrong arguments. 2018-06-04 15:14:50 +08:00
Yossi Gottlieb
e1222d8b10 Clean gcc 7.x warnings, redis-cli cluster fix. 2018-06-03 15:54:30 +03:00
michael-grunder
1749fe7a26 Return early in XPENDING if sent a nonexistent consumer group. 2018-06-02 18:22:20 -07:00
WuYunlong
7d269d5e63 Fix DEBUG LOADAOF so that redis-server will not crash unexpectedly
and will not be inconsistent after we call debug loadaof.
Before this commit, there were 2 problems:

1, When appendonly is set to no and there is not a appendonly file,
   redis-server will crash if we call DEBUG LOADAOF.
2, When appendonly is set to no and there is a appendonly file,
   redis-server will hold different data after loading  appendonly
   file.
2018-06-02 14:32:16 +08:00
Salvatore Sanfilippo
86de089a1e
Merge pull request #4907 from youjiali1995/fix-dictScan
Fix dictScan(): It can't scan all buckets when dict is shrinking.
2018-06-01 16:54:05 +02:00
artix
d168b245b3 Cluster Manager: fixed master_id check in clusterManagerNodeLoadInfo 2018-06-01 16:19:47 +02:00
Salvatore Sanfilippo
d49d023828
Merge pull request #4971 from soloestoy/bugfix-bzpop
ZPOP: unblock multiple clients in right way
2018-05-31 18:40:53 +02:00
zhaozhao.zz
b9d19371e4 ZPOP: unblock multiple clients in right way 2018-05-31 23:35:47 +08:00
Salvatore Sanfilippo
2dee9a4118
Merge pull request #4945 from GitHubMota/debug_recover
Fix debug crash-and-recover help info.
2018-05-31 17:32:11 +02:00
Salvatore Sanfilippo
5bf08449f9
Merge pull request #4953 from soloestoy/fix-memory-overhead
MEMORY: fix the missing of monitor clients buffers
2018-05-31 17:31:24 +02:00
Salvatore Sanfilippo
f3b48978f2
Merge pull request #4964 from remicollet/issue-uint64
include stdint.h for unit64_t definition
2018-05-31 17:20:33 +02:00
antirez
2f963080c1 Capitalize OBJECT HELP subcommands. 2018-05-31 17:11:46 +02:00
artix
4bce88b11f Cluster Manager: fixed infinite loop in rebalance (Issue #4941). 2018-05-31 15:59:16 +02:00
Remi Collet
9561fec496 include stdint.h for unit64_t definition 2018-05-30 15:33:06 +02:00
antirez
3d5e2c62e2 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-05-29 12:41:07 +02:00
antirez
49147f36e9 Don't expire keys while loading RDB from AOF preamble.
The AOF tail of a combined RDB+AOF is based on the premise of applying
the AOF commands to the exact state that there was in the server while
the RDB was persisted. By expiring keys while loading the RDB file, we
change the state, so applying the AOF tail later may change the state.

Test case:

* Time1: SET a 10
* Time2: EXPIREAT a $time5
* Time3: INCR a
* Time4: PERSIT A. Start bgrewiteaof with RDB preamble. The value of a is 11 without expire time.
* Time5: Restart redis from the RDB+AOF: consistency violation.

Thanks to @soloestoy for providing the patch.
Thanks to @trevor211 for the original issue report and the initial fix.

Check issue #4950 for more info.
2018-05-29 12:37:42 +02:00
WuYunlong
2a887bd53f Fix rdb save by allowing dumping of expire keys, so that when
we add a new slave, and do a failover, eighter by manual or
not, other local slaves will delete the expired keys properly.
2018-05-29 12:35:15 +02:00
zhaozhao.zz
ce2e0c02fc MEMORY: fix the missing of monitor clients buffers 2018-05-27 16:34:58 +08:00
antirez
6536ce27a4 Streams: fix comments referring to old ID format. 2018-05-25 17:25:19 +02:00
zhaozhao.zz
c2d7e6cea7 avoid warning in t_stream.c 2018-05-25 22:49:49 +08:00
antirez
fb9c1c3dbd Simplify XADD ID syntax error code path,. 2018-05-25 16:29:37 +02:00
Salvatore Sanfilippo
a60f553b68
Merge pull request #4832 from 0xtonyxia/fix-xadd-ID-parse
Bugfix: xadd command ID parse
2018-05-25 16:27:21 +02:00
antirez
95fa564add Avoid warning by explicitly initializing var to NULL. 2018-05-25 16:19:14 +02:00
antirez
b2b4e186a2 Explicitly cast void pointers to char pointers for printf style logging. 2018-05-25 16:15:59 +02:00
zhaozhao.zz
2711f053f2 append -lrt to FINAL_LIBS for linux 2018-05-25 20:16:57 +08:00
antirez
e4f5c04930 Don't append libjemalloc.a otherwise it will be after -ldl. 2018-05-25 13:36:51 +02:00
Mota
af3471a5dc Fix debug crash-and-recover help info. 2018-05-25 16:49:23 +08:00
antirez
694145bd74 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-05-24 18:21:23 +02:00
antirez
98d5d3f118 Make active defragmentation tests optional.
They failed when active defrag could not be activated because the
Jemalloc version does not include the additional APIs.
2018-05-24 18:04:21 +02:00
Salvatore Sanfilippo
b23a501135
Merge pull request #4099 from JunHe77/aarch64_stack_cflag
Fixed stack trace generation on aarch64
2018-05-24 16:16:12 +02:00
Salvatore Sanfilippo
18b7f71130
Merge pull request #4932 from 0xtonyxia/fix-redis-cli-set-prefer-memory-leak
Fix redis-cli memory leak when sending set :preference command.
2018-05-24 16:15:21 +02:00
Salvatore Sanfilippo
ef7ccad180
Merge pull request #4922 from 0xtonyxia/enhance-cli-security
Enhance security for redis-cli
2018-05-24 16:14:42 +02:00
Salvatore Sanfilippo
8a200b04c3
Merge pull request #4831 from 0xtonyxia/fix-xadd-arity-check
Bugfix: xadd comand <field,value> arity check
2018-05-24 16:07:19 +02:00
antirez
de4b6cb27b Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-05-23 17:14:59 +02:00
antirez
8631e64779 Sentinel: fix delay in detecting ODOWN.
See issue #2819 for details. The gist is that when we want to send INFO
because we are over the time, we used to send only INFO commands, no
longer sending PING commands. However if a master fails exactly when we
are about to send an INFO command, the PING times will result zero
because the PONG reply was already received, and we'll fail to send more
PINGs, since we try only to send INFO commands: the failure detector
will delay until the connection is closed and re-opened for "long
timeout".

This commit changes the logic so that we can send the three kind of
messages regardless of the fact we sent another one already in the same
code path. It could happen that we go over the message limit for the
link by a few messages, but this is not significant. However now we'll
not introduce delays in sending commands just because there was
something else to send at the same time.
2018-05-23 17:13:44 +02:00
Salvatore Sanfilippo
1ab3c82375
Merge pull request #4908 from soloestoy/aof-rdb-preamble-compatible-checksum-no
AOF & RDB: be compatible with rdbchecksum no
2018-05-23 17:11:00 +02:00
zhaozhao.zz
4e7a160b9b ZPOP: fix the wrong keyc, should be 1 2018-05-22 21:31:22 +08:00
dejun.xdj
46e241ac8e Fix redis-cli memory leak when sending set preference command. 2018-05-21 12:19:37 +08:00
dejun.xdj
95b988b6c6 Check if the repeat value is positive in while loop of cliSendCommand().
In case that the incoming repeat parameter is negative and causes a
deadless loop.
2018-05-21 12:06:48 +08:00
dejun.xdj
cc7ffdfdf2 Change the type of repeat argument to long for function cliSendCommand.
To be in consistent with the original definition.
2018-05-21 12:04:53 +08:00
dejun.xdj
b2762f1ff2 Fix negtive repeat command value issue.
If command like "-1 set a b" is sent with redis-cli, it will cause a deadless loop. So some repeat value checking logic is added to avoid this.
2018-05-19 22:50:40 +08:00
dejun.xdj
c2e2314640 Detect and stop saving history for auth command with repeat option.
Put the repeat option checking code a little forward to avoid repeat logic.
2018-05-18 11:40:05 +08:00
dejun.xdj
ef931ef93e Change the warning message a little bit to avoid trademark issuses. 2018-05-18 11:37:31 +08:00
antirez
3c968ff030 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-05-17 16:53:14 +02:00
antirez
3c43e984db Merge remote-tracking branch 'artix/trib2cli' into unstable 2018-05-17 16:52:31 +02:00
Oran Agra
ad133e1023 Active defrag fixes for 32bit builds
problems fixed:
* failing to read fragmentation information from jemalloc
* overflow in jemalloc fragmentation hint to the defragger
* test suite not triggering eviction after population
2018-05-17 09:52:00 +03:00
artix
e47c751c74 Removed TODO in redis-cli 2018-05-16 18:04:13 +02:00
artix
1e4fb1b33a Cluster Manager: fixed unprinted reply error 2018-05-16 17:49:18 +02:00
dejun.xdj
b263c7c465 Stop saving auth command in redis-cli history. 2018-05-16 16:18:00 +08:00
dejun.xdj
c082221aef Add warning message when using password on command line 2018-05-16 16:15:12 +08:00
artix
2f9c032a13 Cluster Manager: print flags as strings. 2018-05-15 18:41:46 +02:00
antirez
25f017e563 ZPOP: fix replication of blocking ZPOP. 2018-05-15 16:03:56 +02:00
artix
3c039996b5 - Fixed mistyped redis command (clusterManagerGetNodeWithMostKeysInSlot)
- Cluster node structure is now updated after ADDSLOTS
2018-05-11 18:29:12 +02:00
antirez
56bbab238a 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
6efb6c1e06 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
antirez
6b026b70a8 Merge branch 'zpop' of https://github.com/itamarhaber/redis into zpop 2018-05-11 10:40:13 +02:00
antirez
b85aae78df Fix rdb.c dictionary iterator release in 2 more places. 2018-05-09 12:06:37 +02:00
antirez
cd87b3c71f Fix rdb.c dictionary iterator release.
Some times it was not released on error, sometimes it was released two
times because the error path expected the "di" var to be NULL if the
iterator was already released. Thanks to @oranagra for pinging me about
potential problems of this kind inside rdb.c.
2018-05-09 11:03:27 +02:00
Salvatore Sanfilippo
aaef5f00cc
Merge pull request #4594 from smallstool/bugfix-freeMemoryIfneeded-int-overflow
fix int overflow problem in freeMemoryIfNeeded
2018-05-08 17:27:18 +02:00
zhaozhao.zz
edb92db533 AOF & RDB: be compatible with rdbchecksum no 2018-05-08 19:22:13 +08:00
赵磊
8d93f924ea Fix dictScan(): It can't scan all buckets when dict is shrinking. 2018-05-08 15:30:11 +08:00
artix
3312de067c Cluster Manager: --cluster options can now be placed everywhere 2018-05-07 17:31:34 +02:00
Krzysztof Filipek
fd9177dd33 Typo in preprocessor condition 2018-05-06 20:18:48 +02:00
Itamar Haber
438125b47c 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
artix
be94e89031 Cluster Manager: fixed expected slots calculation (rebalance)
Cluster Manager: fixed argument parsing after --cluster-weight
2018-04-23 16:28:48 +02:00
artix
2f31545beb Cluster Manager: fixed bug when parsing CLUSTER NODES reply (clusterManagerNodeLoadInfo) 2018-04-23 16:28:48 +02:00
artix
5bc2c98789 Cluster Manager: code improvements and more comments added. 2018-04-23 16:28:48 +02:00
artix
5f358dae33 Cluster Manager: set-timeout command 2018-04-23 16:28:48 +02:00
artix
52f17f6f8e - Cluster Manager: del-node command.
- Cluster Manager: fixed bug in clusterManagerNodeWithLeastReplicas
2018-04-23 16:28:48 +02:00
artix
aeaf6ee1c3 Cluster Manager: add-node command. 2018-04-23 16:28:48 +02:00
artix
efa51f1617 Cluster Manager: added clusterManagerCheckCluster to import command 2018-04-23 16:28:48 +02:00
artix
1f548359cb Cluster Manager: import command 2018-04-23 16:28:48 +02:00
artix
3f8a4adb49 Cluster Manager: fix command. 2018-04-23 16:28:48 +02:00
artix
6d1a7cec23 Cluster Manager: rebalance command 2018-04-23 16:28:48 +02:00
artix
adebee8adc clusterManagerAddSlots: changed the way ADDSLOTS command is built 2018-04-23 16:28:48 +02:00
artix
a4a1c7bb52 ClusterManager: fixed --cluster-from 'all' parsing 2018-04-23 16:28:48 +02:00
Artix
5b3d73b3d7 Cluster Manager: fixed some memory error 2018-04-23 16:28:48 +02:00
artix
220375b424 Fixed memory write error in clusterManagerGetConfigSignature 2018-04-23 16:28:48 +02:00
artix
99da9c9508 Cluster Manager: reshard command, fixed slots
parsing bug and other minor bugs.
2018-04-23 16:28:48 +02:00
artix
7d609ff952 Cluster Manager:
- Almost all Cluster Manager related code moved to
  the same section.
- Many macroes converted to functions
- Added various comments
- Little code restyling
2018-04-23 16:28:48 +02:00
artix
4e0c2f9c3c - Fixed bug in clusterManagerGetAntiAffinityScore
- Code improvements
2018-04-23 16:28:48 +02:00
artix
18910013cd Cluster Manager: colorized output 2018-04-23 16:28:48 +02:00
artix
307d995f75 Cluster Manager: improved cleanup/error handling in various functions 2018-04-23 16:28:48 +02:00
artix
2d677e2bf3 Cluster Manager: 'call' command. 2018-04-23 16:28:48 +02:00
artix
1ad1f00163 Cluster Manager: CLUSTER_MANAGER_NODE_CONNECT macro 2018-04-23 16:28:48 +02:00
artix
2f48d62423 ClusterManager: added replicas count to clusterManagerNode 2018-04-23 16:28:48 +02:00
artix
c002b95d89 Cluster Manager: cluster is considered consistent if only one node has been found 2018-04-23 16:28:48 +02:00
artix
4cc8de1a37 Cluster Manager: reply error catch for MEET command 2018-04-23 16:28:48 +02:00
artix
65d37960e7 Cluster Manager: slots coverage check. 2018-04-23 16:28:48 +02:00
artix
b3e0ca3412 - Cluster Manager: fixed various memory leaks
- Cluster Manager: fixed flags assignment in
  clusterManagerNodeLoadInfo
2018-04-23 16:28:48 +02:00
artix
8c7ad80f9f Added check for open slots (clusterManagerCheckCluster) 2018-04-23 16:28:47 +02:00
artix
486c7af7b8 Cluster Manager: 'create', 'info' and 'check' commands 2018-04-23 16:28:47 +02:00
artix
ad911a338a Cluster Manager mode 2018-04-23 16:28:47 +02:00
zhaozhao.zz
24036b4d32 RDB: expand dict if needed when rdb load object 2018-04-22 22:30:44 +08:00
antirez
e6b0e8d9ec Streams: XTRIM command added. 2018-04-19 16:25:29 +02:00
antirez
19ae809458 Streams: XADD, handle signaling of write in different ways. 2018-04-19 16:11:43 +02:00
antirez
aba76320d5 Streams: XDEL command. 2018-04-18 13:12:09 +02:00
antirez
9c149bf1f1 Streams: higher level "delete by ID" API for streams. 2018-04-17 17:55:56 +02:00
antirez
24ac2b4c74 Streams: iterator entry deletion abilities. 2018-04-17 17:18:00 +02:00
zhaozhao.zz
775adf544c Modules Timer API: fix wrong raxInsert() usage 2018-04-14 01:20:02 +08:00
antirez
e07af6a2b7 Modules API: Add call to get the blocked client handle from the context.
This is useful in the reply and timeout callback, if the module wants to
do some cleanup of the blocked client handle that may be stored around
in the module-private data structures.
2018-04-13 13:48:11 +02:00
antirez
da0e192277 Modules API: moduleGetReplyClient() refactoring. 2018-04-13 13:42:49 +02:00
antirez
404160a271 Modules API: blocked client disconnection callback. 2018-04-12 13:21:48 +02:00
antirez
005c932f22 Modules API: fix timer example. 2018-04-12 13:00:18 +02:00
antirez
4e53624052 Modules API: fix OOM_WARNING flag implementation. 2018-04-11 16:25:54 +02:00
antirez
0afac6939a Modules API: OOM_WARNING flags.
In some modules it may be useful to have an idea about being near to
OOM. Anyway additionally an explicit call to get the fill ratio will be
added in the future.
2018-04-11 16:22:52 +02:00
antirez
de7de53e64 getMaxmemoryState() fixed and improved. 2018-04-11 12:48:26 +02:00
dejun.xdj
b6b00f35ca Return more accurate message when specified ID is invalid 2018-04-10 17:11:10 +08:00
dejun.xdj
3c20b3fc24 Bugfix: xadd command ID parse
strictly check the string to be converted,
strtoull() in libc may not set errno to EINVAL when the string contains
invalid digits.
2018-04-10 17:05:48 +08:00
dejun.xdj
07125b8d22 Bugfix: xadd comand <field,value> arity check
missing parenthesis causes wrong arithmetic priority.
2018-04-10 16:36:05 +08:00
antirez
f97efe0cac Modules: context flags now include OOM flag.
Plus freeMemoryIfNeeded() refactoring to improve legibility.
Please review this commit for sanity.
2018-04-09 17:44:30 +02:00
antirez
6888c1a10d freeMemoryIfNeeded() lacked a top comment. 2018-04-09 17:20:36 +02:00
antirez
9a0dbbb594 Modules: remove trailing empty spaces. 2018-04-09 17:16:55 +02:00
antirez
eaafea4828 Modules API: experimental APIs version.
This way it is possible to use conditional compilation to be compatible
with a larger amount of Redis versions, however note that this breaks
binary compatibiltiy, so the module must be compiled with the
corresponding redismodule.h file depending on the version of Redis
targeted.
2018-04-09 12:17:19 +02:00
antirez
49e098234a Modules API: blocked client free callback modified to get a context.
Note that this was an experimental API that can only be enabled with
REIDSMODULE_EXPERIMENTAL_API, so it is subject to change until its
promoted to stable API. Sorry for the breakage, it is trivial to
resolve btw. This change will not be back ported to Redis 4.0.
2018-04-09 11:54:44 +02:00
antirez
b2868c7b9c Modules API: RM_GetRandomBytes() / GetRandomHexChars(). 2018-04-05 13:24:22 +02:00
antirez
c75582889a Modules Cluster API: GetClusterSize() added. 2018-04-01 16:36:32 +02:00
antirez
27f9c8108c Modules Cluster API: GetMyClusterID() added. 2018-04-01 16:20:57 +02:00
antirez
19c42c901b Modules Timer API: add example of API. 2018-03-31 10:12:34 +02:00
antirez
ee982f4031 Modules Timer API: Wait at least 1 ms per iteration. Convert to ms. 2018-03-31 10:11:30 +02:00
antirez
4c11bc6cf0 Modules Timer API: fix wrong raxRemove() key argument. 2018-03-31 09:58:43 +02:00
antirez
2f7da0fd1a Modules Timer API: fix infinite loop and export API. 2018-03-31 00:44:46 +02:00
antirez
b85a465c25 Modules Timer API: timer handling implemented. 2018-03-30 22:50:21 +02:00
antirez
561039c125 Modules Timer API: initial implementation. 2018-03-30 20:40:35 +02:00
antirez
192361b562 Modules Cluster API: node API exported, example improved. 2018-03-30 17:00:45 +02:00
antirez
16178b692e Modules Cluster API: nodes list and info API. 2018-03-30 16:16:47 +02:00
antirez
83ec35770e Modules Cluster API: node information struct and flags. 2018-03-30 13:16:55 +02:00
antirez
a97df1a6e1 Modules Cluster API: make node IDs pointers constant. 2018-03-30 13:16:07 +02:00
antirez
061f03d730 Modules Cluster API: add a simple example module. 2018-03-30 12:49:45 +02:00
antirez
82004f9dbe Modules Cluster API: fix new API calls exporting. 2018-03-30 12:49:16 +02:00
antirez
b4dc782e4e Modules Cluster API: sending / receiving API first implementation. 2018-03-30 11:06:08 +02:00
antirez
0701cad3de Modules Cluster API: message bus implementation. 2018-03-29 15:13:31 +02:00
zhaozhao.zz
83cf0e3668 adjust position of _dictNextPower in dictExpand 2018-03-29 17:36:15 +08:00
antirez
8ac7af1c5d Fix ae.c when a timer finalizerProc adds an event.
While this feature is not used by Redis, ae.c implements the ability for
a timer to call a finalizer callback when an timer event is deleted.
This feature was bugged since the start, and because it was never used
we never noticed a problem. However Anthony LaTorre was using the same
library in order to implement a different system: he found a bug that he
describes as follows, and which he fixed with the patch in this commit,
sent me by private email:

    --- Anthony email ---

've found one bug in the current implementation of the timed events.
It's possible to lose track of a timed event if an event is added in
the finalizerProc of another event.

For example, suppose you start off with three timed events 1, 2, and
3. Then the linked list looks like:

3 -> 2 -> 1

Then, you run processTimeEvents and events 2 and 3 finish, so now the
list looks like:

-1 -> -1 -> 2

Now, on the next iteration of processTimeEvents it starts by deleting
the first event, and suppose this finalizerProc creates a new event,
so that the list looks like this:

4 -> -1 -> 2

On the next iteration of the while loop, when it gets to the second
event, the variable prev is still set to NULL, so that the head of the
event loop after the next event will be set to 2, i.e. after deleting
the next event the event loop will look like:

2

and the event with id 4 will be lost.

I've attached an example program to illustrate the issue. If you run
it you will see that it prints:

```
foo id = 0
spam!
```

But if you uncomment line 29 and run it again it won't print "spam!".

    --- End of email ---

Test.c source code is as follows:

    #include "ae.h"
    #include <stdio.h>

    aeEventLoop *el;

    int foo(struct aeEventLoop *el, long long id, void *data)
    {
	printf("foo id = %lld\n", id);

	return AE_NOMORE;
    }

    int spam(struct aeEventLoop *el, long long id, void *data)
    {
	printf("spam!\n");

	return AE_NOMORE;
    }

    void bar(struct aeEventLoop *el, void *data)
    {
	aeCreateTimeEvent(el, 0, spam, NULL, NULL);
    }

    int main(int argc, char **argv)
    {
	el = aeCreateEventLoop(100);

	//aeCreateTimeEvent(el, 0, foo, NULL, NULL);
	aeCreateTimeEvent(el, 0, foo, NULL, bar);

	aeMain(el);

	return 0;
    }

Anthony fixed the problem by using a linked list for the list of timers, and
sent me back this patch after he tested the code in production for some time.
The code looks sane to me, so committing it to Redis.
2018-03-28 14:11:04 +02:00
antirez
28d28ef3cf AOF: enable RDB-preamble rewriting by default.
There are too many advantages in doing this, RDB is faster to persist,
more compact, much faster to load back. The main issues here are that
the code is less tested because this was not the old default (so we are
enabling it for the new 5.0 release), and that the AOF is no longer a
trivially parsable format from now on. However the non-preamble mode
will be supported in the future as well, if new data types will be
added.
2018-03-25 11:43:30 +02:00
antirez
8b20112860 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2018-03-23 17:21:46 +01:00
antirez
1392c83fb8 CG: AOF rewriting implemented. 2018-03-23 17:21:31 +01:00
Salvatore Sanfilippo
e08d6bb37e
Merge pull request #4703 from gechunlin/unstable
Update object.c
2018-03-22 16:32:45 +01:00
Salvatore Sanfilippo
bad679137e
Merge pull request #4679 from youjiali1995/fix-lru
Some commands will udpate lfu-counter many times in one call.
2018-03-22 16:26:01 +01:00
Salvatore Sanfilippo
44f2cfa631
Merge pull request #4722 from charsyam/feature/refactoring-call-aeDeleteFileEvent-twice-in-freeClusterLink
Refactoring to call aeDeleteFileEvent twice as once
2018-03-22 16:23:40 +01:00
Salvatore Sanfilippo
b38f52169b
Merge pull request #4777 from soloestoy/avoid-double-close
anet: avoid double close
2018-03-22 16:22:32 +01:00
Salvatore Sanfilippo
3163c9cb63
Merge pull request #4781 from guybe7/block_list_notify
Make blocking list commands send keyspace notifications
2018-03-22 16:21:19 +01:00
antirez
6c4cb1670a Add top comments in two addReply*() functions. 2018-03-22 11:45:04 +01:00
antirez
b86c26b2fd Massivily simplify addReply*() functions in networking.c 2018-03-22 11:42:50 +01:00
Guy Benoish
fa00e20b16 Make blocking list commands send keyspace notifications 2018-03-22 17:22:26 +07:00
Salvatore Sanfilippo
5d8c89163c
Merge pull request #4757 from charsyam/feature/fix-invalid-listpack-type-in-makefile
fix listpack.c to listpack.o in Makefile
2018-03-22 09:20:17 +01:00
Salvatore Sanfilippo
7acf0e0a18
Merge pull request #3826 from charsyam/feature/fix_dlopen_leak
fix missed dlclose leak in module.c
2018-03-22 09:19:26 +01:00
Salvatore Sanfilippo
da621783f0
Merge pull request #4691 from oranagra/active_defrag_v2
Active defrag v2
2018-03-22 09:16:32 +01:00
charsyam
71c7477fd4 fix memory leak for streamPropagateXCLAIM 2018-03-21 17:41:59 +09:00
zhaozhao.zz
46f767aa19 fix missed call on freeaddrinfo 2018-03-21 15:34:13 +08:00
zhaozhao.zz
11baa8487c anet: avoid double close 2018-03-21 15:13:51 +08:00
antirez
233da29f4d CG: propagate XACK by incrementing server.dirty.
This should be more than enough, even if in case of partial IDs that are
not found, we send all the IDs to the slave/AOF, but this is definitely
a corner case without bad effects if not some wasted space.
2018-03-20 17:53:45 +01:00
antirez
0f2c6b6a18 Streams: improve MEMORY USAGE computation, include CGs. 2018-03-20 17:50:40 +01:00
antirez
5577130451 CG: Make XINFO Great Again (and more Redis-ish).
With XINFO out of the blue I invented a new syntax for commands never
used in Redis in the past... Let's fix it and make it

        Great Again!!11one (TM)
2018-03-20 11:52:42 +01:00
antirez
2ba9a57c9a CG: Add JUSTID to XCLAIM propagation to reduce CPU usage. 2018-03-20 11:25:49 +01:00
antirez
ad716e29c0 CG: Fix propagate() arg count in streamPropagateXCLAIM(). 2018-03-20 11:13:41 +01:00
antirez
3cae5f0321 CG: XGROUP CREATE/DELCONUSMER replication. 2018-03-20 11:07:01 +01:00
antirez
0b58ad301e CG: Replication WIP 1: XREADGROUP and XCLAIM propagated as XCLAIM. 2018-03-19 18:02:19 +01:00
antirez
36b78e8dfe Aesthetic changes to PR #4749. 2018-03-16 16:57:53 +01:00
antirez
7e3c583532 Merge branch 'hyperloglog-improvement' of https://github.com/oertl/redis into oertl-hyperloglog-improvement 2018-03-16 16:27:38 +01:00
antirez
38bc8ea531 RDB version 9. 2018-03-16 13:48:44 +01:00
antirez
8b0cfb1e66 RDB: Implement future-proof module AUX data loading. 2018-03-16 13:47:10 +01:00
zhaozhao.zz
54cae05ea7 rdb: incremental fsync when redis saves rdb 2018-03-16 00:44:50 +08:00
antirez
b1aae86fc6 RDB: make RDB check aware of LFU/LRU opcodes. 2018-03-15 16:39:33 +01:00
antirez
8176a2ee76 RDB: LRU/LFU branches missed continue. 2018-03-15 16:33:18 +01:00
antirez
1ce50a7adf RDB: Ability to load LFU/LRU info. 2018-03-15 16:24:53 +01:00
antirez
d7a5c0eb71 RDB: Ability to save LFU/LRU info.
This is a big win for caching use cases, since on reloading Redis will
still have some idea about what is worth to evict and what not.
However this only solves part of the problem because the information is
only partially propagated to slaves (on write operations). Reads will
not affect slaves LFU and LRU counters, so after a failover the eviction
decisions are kinda random until keys start to collect some aging/freq info.

However since new slaves are initially populated via RDB file transfer,
this means that if we spin up a new slave from a master, and perform an
immediate manual failover (for instance in order to upgrade the master),
the slave will have eviction informations to use for some time.

The LFU/LRU info is persisted only if the maxmemory policy is set to one
of the relevant type, even if no actual "maxmemory"  memory limit is
set.
2018-03-15 13:15:55 +01:00
antirez
6614361615 CG: XINFO STREAM. 2018-03-15 12:54:10 +01:00
antirez
d7d8cd0b2f CG: XINFO GROUPS + output format changes.
XINFO is mainly an observability command that will be used more by
humans than computers, and even when used by computers it will be a very
low traffic command. For this reason the format was changed in order to
have field names. They'll consume some bandwidth and CPU cycles, but in
this context this is much better than having to understand what the
numbers in the output array are.
2018-03-15 12:54:10 +01:00
antirez
0cf6b1e3ae CG: XINFO CONSUMERS implemented. 2018-03-15 12:54:10 +01:00
antirez
67eeeb0b10 Streams: fix XREAD missing check for NULL object. 2018-03-15 12:54:10 +01:00
antirez
8d8755c7b5 CG: throw an error if XREADGROUP is used without GROUP. 2018-03-15 12:54:10 +01:00
antirez
d4f81ebdba CG: XGROUP DELCONSUMER implemented. 2018-03-15 12:54:10 +01:00
antirez
9b423ae237 CG: remove stale comment. XREADGROUP is now implemented. 2018-03-15 12:54:10 +01:00
antirez
e6d434c167 CG: implement RETRYCOUNT in XCLAIM. 2018-03-15 12:54:10 +01:00
antirez
f3d9520ccb CG: fix CG RDB loading not found conditional. 2018-03-15 12:54:10 +01:00
antirez
34614a1508 CG: NACK created by XCLAIM FORCE must be set in global PEL. 2018-03-15 12:54:10 +01:00
antirez
596264aee9 CG: implement XCLAIM FORCE option. 2018-03-15 12:54:10 +01:00
antirez
b26f03bd69 CG: XCLAIM now updates the idle time of the message. 2018-03-15 12:54:10 +01:00
antirez
f7d4c3acdf Streams: trap more errors in stream loading + RDB check type name. 2018-03-15 12:54:10 +01:00
antirez
8727b4845b CG: XCLAIM, use minidle and fix array len. 2018-03-15 12:54:10 +01:00
antirez
09e3b3b975 CG: remove unused argument from streamReplyWithRangeFromConsumerPEL(). 2018-03-15 12:54:10 +01:00
antirez
13ff7bc3ef CG: fix RDB saving when there are no consumer groups. 2018-03-15 12:54:10 +01:00
antirez
267f7f2c97 Streams: fix error description for XADD when specified ID is small. 2018-03-15 12:54:10 +01:00