Commit Graph

6573 Commits

Author SHA1 Message Date
antirez
30adc62232 RDB: load files faster avoiding useless free+realloc.
Reloading of the RDB generated by

    DEBUG POPULATE 5000000
    SAVE

is now 25% faster.

This commit also prepares the ability to have more flexibility when
loading stuff from the RDB, since we no longer use dbAdd() but can
control exactly how things are added in the database.
2020-04-09 10:24:46 +02:00
antirez
96a54866ab Speedup: unblock clients on keys in O(1).
See #7071.
2020-04-08 12:55:57 +02:00
hayleeliu
51b9de037d
fix spelling mistake in bitops.c 2020-04-08 18:20:32 +08:00
antirez
96688aa646 Fix ACL HELP table missing comma. 2020-04-08 10:56:47 +02:00
antirez
a6350f717d Merge branch 'unstable' of github.com:/antirez/redis into unstable 2020-04-07 14:10:43 +02:00
antirez
f69876280c Speedup INFO by counting client memory incrementally.
Related to #5145.

Design note: clients may change type when they turn into replicas or are
moved into the Pub/Sub category and so forth. Moreover the recomputation
of the bytes used is problematic for obvious reasons: it changes
continuously, so as a conservative way to avoid accumulating errors,
each client remembers the contribution it gave to the sum, and removes
it when it is freed or before updating it with the new memory usage.
2020-04-07 12:07:54 +02:00
Salvatore Sanfilippo
e93dcba46e
Merge pull request #7064 from mymilkbottles/unstable
Optimize lua log level judgment
2020-04-06 17:34:14 +02:00
Salvatore Sanfilippo
9a9109431b
Merge pull request #7065 from qetu3790/unstable
fix comments about RESIZE DB opcode in rdb.c
2020-04-06 17:32:44 +02:00
Salvatore Sanfilippo
094b47391d
Merge pull request #6243 from soloestoy/expand-lazy-free-server-del
lazyfree: add a new configuration lazyfree-lazy-user-del
2020-04-06 17:27:39 +02:00
qetu3790
2c42f6a8b8
fix comments about RESIZE DB opcode in rdb.c
fix comments about RESIZE DB opcode in rdb.c
2020-04-06 20:52:32 +08:00
antirez
121c51f4f3 Merge branch 'lcs' into unstable 2020-04-06 13:51:55 +02:00
antirez
ca8d6f1072 LCS: allow KEYS / STRINGS to be anywhere.
Initially they needed to be at the end so that we could extend to N
strings in the future, but after further consideration I no longer
believe it's worth it.
2020-04-06 13:48:31 +02:00
antirez
7261a5550f LCS: get rid of STOREIDX option. Fix get keys helper. 2020-04-06 13:32:15 +02:00
mymilkbottles
25063f75d7
Judge the log level in advance 2020-04-06 19:27:06 +08:00
Salvatore Sanfilippo
af5c11874c
Merge pull request #6797 from patpatbear/issue_#6565_memory_borderline
Check OOM at script start to get stable lua OOM state.
2020-04-06 11:59:01 +02:00
Guy Benoish
a76a961cdd Use __attribute__ only if __GNUC__ is defined 2020-04-03 14:49:40 +03:00
Salvatore Sanfilippo
f80b946bea
Merge pull request #6855 from guybe7/var_funcs_format_check
Modules: Perform printf-like format checks in variadic API
2020-04-03 13:46:27 +02:00
Guy Benoish
a8857320a5 Modules: Perform printf-like format checks in variadic API 2020-04-03 14:39:55 +03:00
Salvatore Sanfilippo
cbf212f981
Merge pull request #7030 from valentinogeron/xread-in-lua
XREAD and XREADGROUP should not be allowed from scripts when BLOCK op…
2020-04-03 11:14:13 +02:00
Salvatore Sanfilippo
4158664d2b
Merge pull request #6933 from guybe7/multi_exec_allow_stale
Stale replica should allow MULTI/EXEC
2020-04-03 11:12:58 +02:00
Salvatore Sanfilippo
4e8e7fb067
Merge pull request #7055 from zxdvd/patch-1
fix integer overflow
2020-04-03 11:10:26 +02:00
antirez
ef610802c7 LCS: fix stale comment. 2020-04-02 21:17:31 +02:00
Salvatore Sanfilippo
eb9ca33414
Merge pull request #6694 from oranagra/signal_modified_key
modules don't signalModifiedKey in setKey() since that's done (optionally) in RM_CloseKey
2020-04-02 19:00:20 +02:00
Xudong Zhang
78df016584 fix integer overflow 2020-04-02 23:43:47 +08:00
Guy Benoish
85a0d29d04 Stale replica should allow MULTI/EXEC
Example: Client uses a pipe to send the following to a
stale replica:

MULTI
.. do something ...
DISCARD

The replica will reply the MUTLI with -MASTERDOWN and
execute the rest of the commands... A client using a
pipe might not be aware that MULTI failed until it's
too late.

I can't think of a reason why MULTI/EXEC/DISCARD should
not be executed on stale replicas...

Also, enable MULTI/EXEC/DISCARD during loading
2020-04-02 18:23:59 +03:00
Salvatore Sanfilippo
0062194d74
Merge pull request #6654 from oranagra/fix_module_info_warning
fix possible warning on incomplete struct init
2020-04-02 16:32:20 +02:00
Salvatore Sanfilippo
10b626b3d5
Merge pull request #6546 from guybe7/fix_neg_zero
Make sure Redis does not reply with negative zero
2020-04-02 16:26:57 +02:00
Salvatore Sanfilippo
2f53ad30ee
Merge pull request #6813 from guybe7/debug_object_pass_keyname
DEBUG OBJECT should pass keyname to module when loading
2020-04-02 16:20:48 +02:00
antirez
5a3d85745a LCS: output LCS len as well in IDX mode. 2020-04-02 16:15:17 +02:00
antirez
3f96e1623d LCS: MINMATCHLEN and WITHMATCHLEN options. 2020-04-02 13:37:35 +02:00
Salvatore Sanfilippo
88351275fe
Merge pull request #6960 from devnexen/debug_arm_linux
debug, dump registers on arm too.
2020-04-02 11:26:08 +02:00
Salvatore Sanfilippo
fa4f50739a
Merge pull request #7006 from hwware/fixspelling
fix spelling in cluster.c clusterDelNode
2020-04-02 11:23:53 +02:00
Salvatore Sanfilippo
dfef407499
Merge pull request #7029 from valentinogeron/fix-xack
XACK should be executed in a "all or nothing" fashion.
2020-04-02 11:23:23 +02:00
Salvatore Sanfilippo
8d6dc136e1
Merge pull request #7041 from hwware/trackingfix
CLIENT TRACKING Command Fix: Add More Checking for OPTIN/OPTOUT mode
2020-04-02 11:22:30 +02:00
Salvatore Sanfilippo
b73d87f5e5
Merge pull request #7039 from guybe7/persist_ksn
PERSIST should notify a keyspace event
2020-04-02 11:21:20 +02:00
Salvatore Sanfilippo
babada8b5f
Merge pull request #7042 from guybe7/stream_cg_last_id_fix
streamReplyWithRange: Redundant XSETIDs to replica
2020-04-02 11:20:54 +02:00
antirez
80ec0431e8 Simplify comment in moduleTryServeClientBlockedOnKey(). 2020-04-02 11:20:09 +02:00
antirez
545a5046f5 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2020-04-02 11:18:33 +02:00
antirez
88e66ecf94 LCS: 7x speedup by accessing the array with better locality. 2020-04-01 23:45:07 +02:00
antirez
8cdc15c309 LCS: implement KEYS option. 2020-04-01 22:11:59 +02:00
antirez
4cbf3f5ddd LCS: other fixes to range emission. 2020-04-01 17:36:32 +02:00
antirez
c9c03c3ee6 LCS: fix emission of last range starting at index 0. 2020-04-01 17:14:40 +02:00
antirez
b3400559be LCS: implement range indexes option. 2020-04-01 17:11:31 +02:00
antirez
1010c1b43e LCS: initial functionality implemented. 2020-04-01 16:13:18 +02:00
Guy Benoish
c4dc5b80b2 Fix memory corruption in moduleHandleBlockedClients
By using a "circular BRPOPLPUSH"-like scenario it was
possible the get the same client on db->blocking_keys
twice (See comment in moduleTryServeClientBlockedOnKey)

The fix was actually already implememnted in
moduleTryServeClientBlockedOnKey but it had a bug:
the funxction should return 0 or 1 (not OK or ERR)

Other changes:
1. Added two commands to blockonkeys.c test module (To
   reproduce the case described above)
2. Simplify blockonkeys.c in order to make testing easier
3. cast raxSize() to avoid warning with format spec
2020-04-01 12:53:26 +03:00
antirez
38076fd6ba cast raxSize() to avoid warning with format spec. 2020-03-31 17:41:46 +02:00
antirez
1d13ff0b39 Minor changes to #7037. 2020-03-31 17:10:09 +02:00
Salvatore Sanfilippo
0c52ce6c8e
Merge pull request #7037 from guybe7/fix_module_replicate_multi
Modules: Test MULTI/EXEC replication of RM_Replicate
2020-03-31 17:00:57 +02:00
Salvatore Sanfilippo
a20c206de7
Merge pull request #7048 from guybe7/rename_unblock_stream
RENAME can unblock XREADGROUP
2020-03-31 16:55:29 +02:00
Guy Benoish
6c8221580c RENAME can unblock XREADGROUP
Other changes:
Support stream in serverLogObjectDebugInfo
2020-03-31 17:41:10 +03:00
Guy Benoish
d6eb3afd13 Modules: Test MULTI/EXEC replication of RM_Replicate
Makse sure call() doesn't wrap replicated commands with
a redundant MULTI/EXEC

Other, unrelated changes:
1. Formatting compiler warning in INFO CLIENTS
2. Use CLIENT_ID_AOF instead of UINT64_MAX
2020-03-31 13:55:51 +03:00
antirez
1b4bc60999 Merge branch 'pubsub_patterns_boost' of https://github.com/leeyiw/redis into leeyiw-pubsub_patterns_boost 2020-03-31 12:40:08 +02:00
antirez
9dcf878f1b Fix module commands propagation double MULTI bug.
37a10cef introduced automatic wrapping of MULTI/EXEC for the
alsoPropagate API. However this collides with the built-in mechanism
already present in module.c. To avoid complex changes near Redis 6 GA
this commit introduces the ability to exclude call() MUTLI/EXEC wrapping
for also propagate in order to continue to use the old code paths in
module.c.
2020-03-31 11:00:45 +02:00
antirez
7698316fda Fix RM_Call() stale comment due to cut&paste. 2020-03-31 10:27:47 +02:00
antirez
f6d5996ead Merge branch 'unstable' of github.com:/antirez/redis into unstable 2020-03-30 17:29:04 +02:00
antirez
3ef59b50c4 Precise timeouts: reference client pointer directly. 2020-03-30 15:22:59 +02:00
Guy Benoish
12d7479144 streamReplyWithRange: Redundant XSETIDs to replica
propagate_last_id is declared outside of the loop but used
only from within the loop. Once it's '1' it will never go
back to '0' and will replicate XSETID even for IDs that
don't actually change the last_id.
While not a serious bug (XSETID always used group->last_id
so there's no risk), it does causes redundant traffic
between master and its replicas
2020-03-30 10:53:03 +03:00
hwware
86c76cad74 add check for not switching between optin optout mode directly 2020-03-29 23:20:54 -04:00
hwware
1ef44f8243 add check for not providing both optin optout flag 2020-03-29 23:06:50 -04:00
Guy Benoish
3f0afab301 PERSIST should notify a keyspace event 2020-03-29 17:50:42 +03:00
Salvatore Sanfilippo
aca7f36b57
Merge pull request #7033 from OMG-By/unstable
fix: dict.c->dictResize()->minimal  type
2020-03-29 16:17:52 +02:00
OMG-By
6d2f1188ac
fix: dict.c->dictResize()->minimal type 2020-03-29 00:04:59 +08:00
zhaozhao.zz
36ee294e83 PSYNC2: reset backlog_idx and master_repl_offset correctly 2020-03-28 20:59:01 +08:00
antirez
dd7e61d77f timeout.c created: move client timeouts code there. 2020-03-27 16:35:03 +01:00
antirez
0e22cb2680 Precise timeouts: cleaup the table on unblock.
Now that this mechanism is the sole one used for blocked clients
timeouts, it is more wise to cleanup the table when the client unblocks
for any reason. We use a flag: CLIENT_IN_TO_TABLE, in order to avoid a
radix tree lookup when the client was already removed from the table
because we processed it by scanning the radix tree.
2020-03-27 16:35:03 +01:00
antirez
13e4c2a9b1 Precise timeouts: fix comments after functional change. 2020-03-27 16:35:03 +01:00
antirez
aa9d92d94a Precise timeouts: use only radix tree for timeouts. 2020-03-27 16:35:03 +01:00
antirez
077f965426 Precise timeouts: fast exit for clientsHandleShortTimeout(). 2020-03-27 16:35:03 +01:00
antirez
8d11e0df7a Precise timeouts: fix bugs in initial implementation. 2020-03-27 16:35:03 +01:00
antirez
324a8c91d0 Precise timeouts: working initial implementation. 2020-03-27 16:35:03 +01:00
antirez
8d116cc8a2 Precise timeouts: refactor unblocking on timeout. 2020-03-27 16:35:02 +01:00
antirez
97f1c808ce PSYNC2: fix backlog_idx when adjusting for meaningful offset
See #7002.
2020-03-27 16:20:02 +01:00
Valentino Geron
9a1843ef2d XREAD and XREADGROUP should not be allowed from scripts when BLOCK option is being used 2020-03-26 15:46:31 +02:00
Valentino Geron
1547d72cf3 XACK should be executed in a "all or nothing" fashion.
First, we must parse the IDs, so that we abort ASAP.
The return value of this command cannot be an error if
the client successfully acknowledged some messages,
so it should be executed in a "all or nothing" fashion.
2020-03-26 15:40:23 +02:00
Salvatore Sanfilippo
2ea7f0ecad
Merge pull request #6644 from oranagra/stream_aofrw
AOFRW on an empty stream created with MKSTREAM loads badkly
2020-03-26 11:12:44 +01:00
Oran Agra
3b29556a0c AOFRW on an empty stream created with MKSTREAM loads badkly
the AOF will be loaded successfully, but the stream will be missing,
i.e inconsistencies with the original db.

this was because XADD with id of 0-0 would error.

add a test to reproduce.
2020-03-25 21:47:57 +02:00
antirez
57fa355e56 PSYNC2: meaningful offset implemented.
A very commonly signaled operational problem with Redis master-replicas
sets is that, once the master becomes unavailable for some reason,
especially because of network problems, many times it wont be able to
perform a partial resynchronization with the new master, once it rejoins
the partition, for the following reason:

1. The master becomes isolated, however it keeps sending PINGs to the
replicas. Such PINGs will never be received since the link connection is
actually already severed.
2. On the other side, one of the replicas will turn into the new master,
setting its secondary replication ID offset to the one of the last
command received from the old master: this offset will not include the
PINGs sent by the master once the link was already disconnected.
3. When the master rejoins the partion and is turned into a replica, its
offset will be too advanced because of the PINGs, so a PSYNC will fail,
and a full synchronization will be required.

Related to issue #7002 and other discussion we had in the past around
this problem.
2020-03-25 15:26:37 +01:00
antirez
f15042dbf0 Explain why we allow transactions in -BUSY state.
Related to #7022.
2020-03-25 12:46:59 +01:00
Oran Agra
ec007559ff MULTI/EXEC during LUA script timeout are messed up
Redis refusing to run MULTI or EXEC during script timeout may cause partial
transactions to run.

1) if the client sends MULTI+commands+EXEC in pipeline without waiting for
response, but these arrive to the shards partially while there's a busy script,
and partially after it eventually finishes: we'll end up running only part of
the transaction (since multi was ignored, and exec would fail).

2) similar to the above if EXEC arrives during busy script, it'll be ignored and
the client state remains in a transaction.

the 3rd test which i added for a case where MULTI and EXEC are ok, and
only the body arrives during busy script was already handled correctly
since processCommand calls flagTransaction
2020-03-23 20:45:32 +02:00
antirez
c80d81c80a Improve comments of replicationCacheMasterUsingMyself(). 2020-03-23 16:17:35 +01:00
antirez
61de1c1146 Fix BITFIELD_RO test. 2020-03-23 12:02:12 +01:00
antirez
918086e253 Abort transactions after -READONLY error. Fix #7014. 2020-03-23 11:47:49 +01:00
antirez
38514e3c8d Minor changes to BITFIELD_RO PR #6951. 2020-03-23 11:28:09 +01:00
Salvatore Sanfilippo
493a7f9823
Merge pull request #6951 from yangbodong22011/feature-bitfield-ro
Added BITFIELD_RO variants for read-only operations.
2020-03-23 11:23:21 +01:00
antirez
19f5be231d Modules: updated function doc after #7003. 2020-03-23 11:17:50 +01:00
Salvatore Sanfilippo
7c5dc07016
Merge pull request #7003 from guybe7/rm_context_flags_handle_null
Allow RM_GetContextFlags to work with ctx==NULL
2020-03-23 11:15:42 +01:00
Salvatore Sanfilippo
b9e5be5f56
Merge pull request #7005 from hwware/memoryleakfix-redis-cli
fix potential memory leak in redis-cli lua debug mode
2020-03-23 11:14:46 +01:00
Salvatore Sanfilippo
89f46f0fa1
Merge pull request #7018 from yossigo/fix-accept-issues
Fix issues with failed/rejected accepts.
2020-03-23 11:10:59 +01:00
Salvatore Sanfilippo
d1788a5ddb
Merge pull request #7019 from hwware/cscfix
Fix Bug for Client Side Caching: Unexpected Behaviour when Switching between OPTIN/OPTOUT Mode
2020-03-23 11:09:55 +01:00
hwware
34d5982bd5 remove redundant Semicolon 2020-03-23 01:07:46 -04:00
hwware
a2732291cd clean CLIENT_TRACKING_CACHING flag when disabled caching 2020-03-23 01:04:49 -04:00
Yossi Gottlieb
2dab5015b7 Fix crashes related to failed/rejected accepts. 2020-03-22 14:47:44 +02:00
Yossi Gottlieb
4c08ae3ff6 Cluster: fix misleading accept errors. 2020-03-22 14:46:16 +02:00
Yossi Gottlieb
fa9aa90813 Conns: Fix connClose() / connAccept() behavior.
We assume accept handlers may choose to reject a connection and close
it, but connAccept() callers can't distinguish between this state and
other error states requiring connClose().

This makes it safe (and mandatory!) to always call connClose() if
connAccept() fails, and safe for accept handlers to close connections
(which will defer).
2020-03-22 14:42:03 +02:00
Salvatore Sanfilippo
5634ee973c
Merge pull request #7013 from hwware/clusterhelpfix
add missing commands description in cluster help
2020-03-20 16:33:10 +01:00
hwware
93bb42a0b5 add missing commands in cluster help 2020-03-20 09:01:12 -04:00
antirez
1e16b9384d Merge branch 'unstable' of github.com:/antirez/redis into unstable 2020-03-20 13:21:28 +01:00
antirez
f9c56dbb09 ACL: default user off should not allow automatic authentication.
This fixes issue #7011.
2020-03-20 12:45:48 +01:00
hwware
262262fbb2 fix spelling in cluster.c 2020-03-18 09:48:03 -04:00
hwware
86691ccff5 fix potentical memory leak in redis-cli 2020-03-18 09:33:52 -04:00