461 Commits

Author SHA1 Message Date
antirez
ab10e0f2fb 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
2ee65aff6b Precise timeouts: fix comments after functional change. 2020-03-27 16:35:03 +01:00
antirez
0264a78063 Precise timeouts: use only radix tree for timeouts. 2020-03-27 16:35:03 +01:00
antirez
c54576c631 Precise timeouts: fast exit for clientsHandleShortTimeout(). 2020-03-27 16:35:03 +01:00
antirez
36cba9bb8e Precise timeouts: fix bugs in initial implementation. 2020-03-27 16:35:03 +01:00
antirez
f232cb6670 Precise timeouts: working initial implementation. 2020-03-27 16:35:03 +01:00
antirez
86bd36d93a Precise timeouts: refactor unblocking on timeout. 2020-03-27 16:35:02 +01:00
antirez
21976106a9 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
27a14b7a32 Explain why we allow transactions in -BUSY state.
Related to #7022.
2020-03-25 12:46:59 +01:00
Oran Agra
fd1e1935a6 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
0558a0b35e Abort transactions after -READONLY error. Fix #7014. 2020-03-23 11:47:49 +01:00
Salvatore Sanfilippo
5f848d8cb3 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
08af68436d Merge branch 'unstable' of github.com:/antirez/redis into unstable 2020-03-20 13:21:28 +01:00
antirez
90f5d83381 ACL: default user off should not allow automatic authentication.
This fixes issue #7011.
2020-03-20 12:45:48 +01:00
WuYunlong
f4a6b931cc Fix master replica inconsistency for upgrading scenario.
Before this commit, when upgrading a replica, expired keys will not
be loaded, thus causing replica having less keys in db. To this point,
master and replica's keys is logically consistent. However, before
the keys in master and replica are physically consistent, that is,
they have the same dbsize, if master got a problem and the replica
got promoted and becomes new master of that partition, and master
updates a key which does not exist on master, but physically exists
on the old master(new replica), the old master would refuse to update
the key, thus causing master and replica data inconsistent.

How could this happen?
That's all because of the wrong judgement of roles while starting up
the server. We can not use server.masterhost to judge if the server
is master or replica, since it fails in cluster mode.

When we start the server, we load rdb and do want to load expired keys,
and do not want to have the ability to active expire keys, if it is
a replica.
2020-03-18 16:22:07 +08:00
zhaozhao.zz
a02e9fc81d Threaded IO: handle pending reads clients ASAP after event loop 2020-03-16 11:20:48 +08:00
bodong.ybd
e0cf09cace Added BITFIELD_RO variants for read-only operations. 2020-03-04 20:51:45 +08:00
antirez
1d048a3b46 Remove RDB files used for replication in persistence-less instances. 2020-03-03 14:58:15 +01:00
Salvatore Sanfilippo
23772a54d7 Merge pull request #6862 from oranagra/command_info_no_auth
add no_auth to COMMAND INFO
2020-02-28 11:05:31 +01:00
antirez
c98236a5f3 Tracking: BCAST: basic feature now works. 2020-02-12 19:22:04 +01:00
antirez
c797326742 Tracking: BCAST: parsing of the options + skeleton. 2020-02-10 17:18:11 +01:00
antirez
dcb43f4530 Tracking: minor change of names and new INFO field. 2020-02-07 18:12:45 +01:00
antirez
ddc2a9f5ee Tracking: rename INFO field with total items. 2020-02-07 17:19:17 +01:00
antirez
bcc9361ad4 Tracking: first conversion from hashing to key names. 2020-02-07 14:03:43 +01:00
Oran Agra
19e6ef248b add no_auth to COMMAND INFO 2020-02-06 14:53:54 +02:00
antirez
2700fae0b7 Merge branch 'unstable' of github.com:/antirez/redis into unstable 2020-02-06 11:24:22 +01:00
Salvatore Sanfilippo
f703f2ac56 Merge pull request #6843 from oranagra/command_flags
A few non-data commands that should be allowed while loading or stale
2020-02-06 10:34:26 +01:00
Guy Benoish
818b77193b Fix small bugs related to replica and monitor ambiguity
1. server.repl_no_slaves_since can be set when a MONITOR client disconnects
2. c->repl_ack_time can be set by a newline from a MONITOR client
3. Improved comments
2020-02-06 14:10:02 +05:30
Oran Agra
ddc1845286 A few non-data commands that should be allowed while loading or stale
SELECT, and HELLO are commands that may be executed by the client
as soon as it connects, there's no reason to block them, preventing the
client from doing the rest of his sequence (which might just be INFO or
CONFIG, etc).

MONITOR, DEBUG, SLOWLOG, TIME, LASTSAVE are all non-data accessing
commands, which there's no reason to block.
2020-02-06 08:53:23 +02:00
Oran Agra
f7067d371b memoryGetKeys helper function so that ACL can limit access to keys for MEMORY command 2020-02-05 09:42:49 +02:00
antirez
debc5d4ef9 ACL LOG: log failed auth attempts. 2020-02-04 12:55:26 +01:00
antirez
f550dfca47 ACL LOG: actually emit entries. 2020-01-28 18:04:20 +01:00
antirez
800425a319 ACL LOG: data structures and initial functions. 2020-01-27 18:37:52 +01:00
antirez
c0bdf0eb73 Change error message for #6775. 2020-01-15 17:55:24 +01:00
Vasyl Melnychuk
9ea3bfdb8b Make error when submitting command in incorrect context more explicit
So error message `ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context` will become
`ERR 'get' command submitted, but only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context`
2020-01-10 23:34:15 +02:00
Salvatore Sanfilippo
95a43c2178 Merge pull request #6615 from soloestoy/wrap-also-propagate-as-multi
Wrap also propagate as multi
2019-12-19 09:24:52 +01:00
Salvatore Sanfilippo
3d344f9467 Merge pull request #6052 from jtru/better-systemd-integration-v2
Better systemd integration v2
2019-12-19 08:54:22 +01:00
Madelyn Olson
05b7628687 Add module APIs for custom authentication 2019-12-17 06:59:59 +00:00
antirez
56694f09f2 Clarify change in #6662. 2019-12-16 11:24:19 +01:00
Salvatore Sanfilippo
448b259548 Merge pull request #6662 from oranagra/fix_hz_div0
init server.hz early to avoid div by 0 during config file loading
2019-12-16 11:18:08 +01:00
Oran Agra
d290b9ca58 init server.hz early to avoid div by 0 during config file loading
since the refactory of config.c, it was initialized from config_hz in initServer
but apparently that's too late since the config file loading creates objects
which call LRU_CLOCK
2019-12-12 17:56:02 +02:00
Salvatore Sanfilippo
96eb0b2b88 Merge pull request #6516 from IAmATeaPot418/patch-2
Add no-slowlog to acl command to prevent passwords
2019-12-12 09:41:19 +01:00
antirez
5b203adbe0 Clients connected and bytes used is too spammy for verbose.
This message is there for ten years, but is hardly useful.
Moreover it is likely that it will fill an entire disk if log ratation
is not configured, for no good reasons.
2019-12-11 10:17:23 +01:00
Oran Agra
493cc493b6 Converting more configs to use generic infra, and moving defaults to config.c
Changes in behavior:
- Change server.stream_node_max_entries from int64_t to long long, so that it can be used by the generic infra
- standard error reply instead of "repl-backlog-size must be 1 or greater" and such
- tls-port and a few TLS booleans were readable (config get) even when USE_OPENSSL was off (now they aren't)
- syslog-enabled, syslog-ident, cluster-enabled, appendfilename, and supervised didn't have a get (now they do)
- pidfile was initialized to NULL in InitServerConfig but had CONFIG_DEFAULT_PID_FILE in rewriteConfig (so the real default was "", but rewrite would cause it to be set), fixed the rewrite.
- TLS config in server.h was uninitialized (if no tls config args were provided)

Adding test for sanity and coverage
2019-11-28 11:24:57 +02:00
Oran Agra
82e997c043 Additional config.c refactory and bugfixes
- add capability for each config to have a callback to check if value is valid and return error string
  will enable converting many of the remaining custom configs into generic ones (reducing the x4 repetition for set,get,config,rewrite)
- add capability for each config to  to run some update code after config is changed (only for CONFIG SET)
  will also enable converting many of the remaining custom configs into generic ones
- add capability to move default values from server.h and server.c to config.c
  will reduce many excess lines in server.h and server.c (plus, no need to rebuild the entire code base when a default change 8-))

other behavior changes:
- fix bug in bool config get (always returning 'yes')
- fix a bug in modifying jemalloc-bg-thread at runtime (didn't call set_jemalloc_bg_thread, due to bad merge conflict resolution (my fault))
- side effect when a failed attempt to enable activedefrag at runtime, we now respond with -ERR and not with -DISABLED
2019-11-26 16:52:28 +02:00
zhaozhao.zz
caddddcd8a block: propagate BRPOPLPUSH as RPOPLPUSH when unblock 2019-11-22 16:38:49 +08:00
zhaozhao.zz
b512cb40b8 Propagation: wrap commands in also_propagate array with MULIT/EXEC
Random command like SPOP with count is replicated as
some SREM operations, and store them in also_propagate
array to propagate after the call, but this would break
atomicity.

To keep the command's atomicity, wrap also_propagate
array with MULTI/EXEC.
2019-11-22 15:42:49 +08:00
Salvatore Sanfilippo
22c68cc3bf Merge branch 'unstable' into rm_get_server_info 2019-11-21 10:06:15 +01:00
Maxim Ivanov
ca70f5f070 Prune leftover TODO comment
Is it sufficient... ? -- Yes it is. In standalone mode, we say READY=1
at the comment point; however in replicated mode, we delay sending
READY=1 until the replication sync completes.
2019-11-20 19:45:25 +02:00
Salvatore Sanfilippo
15664acd87 Merge pull request #6559 from oranagra/active_defrag_tunables
Adjustments for active defrag defaults
2019-11-20 10:08:08 +01:00