20927 Commits

Author SHA1 Message Date
Yossi Gottlieb
945983ac52 Introduce getKeysResult for getKeysFromCommand.
Avoid using a static buffer for short key index responses, and make it
caller's responsibility to stack-allocate a result type. Responses that
don't fit are still allocated on the heap.

(cherry picked from commit 9b7f8ba84b9de1ec846badd45e4004e3cd23f178)
2020-10-27 09:12:01 +02:00
Madelyn Olson
ec9b1cca59 Fixed excessive categories being displayed from acls (#7889)
(cherry picked from commit abe416c5f251b7b151440b38829a719c4846b8b8)
2020-10-27 09:12:01 +02:00
Madelyn Olson
e7c8002b56 Fixed excessive categories being displayed from acls (#7889)
(cherry picked from commit 2127f7c8ebc1d8638eb0c99764f698cebcdb6513)
2020-10-27 09:12:01 +02:00
Oran Agra
9cf7292ef7 Add some additional signal info to the crash log (#7891)
- si_code can be very useful info some day.
- a clear indication that redis was killed by an external user

(cherry picked from commit 38c7c62d2270b4921219953aaabfcdc721154b88)
2020-10-27 09:12:01 +02:00
Oran Agra
86b5e1a72f Add some additional signal info to the crash log (#7891)
- si_code can be very useful info some day.
- a clear indication that redis was killed by an external user

(cherry picked from commit f659d236196ec57b02148031f425cf8864ed77ad)
2020-10-27 09:12:01 +02:00
Oran Agra
6e03b388ce Allow blocked XREAD on a cluster replica (#7881)
I suppose that it was overlooked, since till recently none of the blocked commands were readonly.

other changes:
- add test for the above.
- add better support for additional (and deferring) clients for
  cluster tests
- improve a test which left the client in MULTI state.

(cherry picked from commit ba61700db24628451212c5875e0ca7e5d83ea743)
2020-10-27 09:12:01 +02:00
Oran Agra
bab834574c Allow blocked XREAD on a cluster replica (#7881)
I suppose that it was overlooked, since till recently none of the blocked commands were readonly.

other changes:
- add test for the above.
- add better support for additional (and deferring) clients for
  cluster tests
- improve a test which left the client in MULTI state.

(cherry picked from commit 216c1106099f7c66c991a5a811c8fbacbb0ab17c)
2020-10-27 09:12:01 +02:00
Oran Agra
a5302a8c21 memory reporting of clients argv (#7874)
track and report memory used by clients argv.
this is very usaful in case clients started sending a command and didn't
complete it. in which case the first args of the command are already
trimmed from the query buffer.

in an effort to avoid cache misses and overheads while keeping track of
these, i avoid calling sdsZmallocSize and instead use the sdslen /
bulk-len which can at least give some insight into the problem.

This memory is now added to the total clients memory usage, as well as
the client list.

(cherry picked from commit 7481e513f0507d01381a87046d8d1366c718f94e)
2020-10-27 09:12:01 +02:00
Oran Agra
76f3a63de1 memory reporting of clients argv (#7874)
track and report memory used by clients argv.
this is very usaful in case clients started sending a command and didn't
complete it. in which case the first args of the command are already
trimmed from the query buffer.

in an effort to avoid cache misses and overheads while keeping track of
these, i avoid calling sdsZmallocSize and instead use the sdslen /
bulk-len which can at least give some insight into the problem.

This memory is now added to the total clients memory usage, as well as
the client list.

(cherry picked from commit bea40e6a41e31a52e9e6efee77ea5a4bd873b759)
2020-10-27 09:12:01 +02:00
DvirDukhan
7a8a268ac4 redis-cli add control on raw format line delimiter (#7841)
Adding -D option for redis-cli to control newline between command
responses in raw mode.

Also removing cleanup code before calling exit, just in order
to avoid adding more adding more cleanup code (redis doesn't
bother to release allocations before exit anyway)

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit f0f8e9c824b819c8aec996ec8c8851773a6f9432)
2020-10-27 09:12:01 +02:00
DvirDukhan
93b4c6b31e redis-cli add control on raw format line delimiter (#7841)
Adding -D option for redis-cli to control newline between command
responses in raw mode.

Also removing cleanup code before calling exit, just in order
to avoid adding more adding more cleanup code (redis doesn't
bother to release allocations before exit anyway)

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 6418d767e86b6fd98ba79253108b2e53966a04b3)
2020-10-27 09:12:01 +02:00
Oran Agra
0d7a1d1d37 Include internal sds fragmentation in MEMORY reporting (#7864)
The MEMORY command is used for debugging memory usage, so it should include internal
fragmentation, same as used_memory

(cherry picked from commit 86483e795262c6e2efdffe92c1642a72ef0dd6a0)
2020-10-27 09:12:01 +02:00
Oran Agra
12055ed8c2 Include internal sds fragmentation in MEMORY reporting (#7864)
The MEMORY command is used for debugging memory usage, so it should include internal
fragmentation, same as used_memory

(cherry picked from commit eb6241a3dd3ee27610922e6bccd44603a9b845e8)
2020-10-27 09:12:01 +02:00
Oran Agra
51dd4677c9 Fix crash in script timeout during AOF loading (#7870)
(cherry picked from commit 8cff3e03520bb08cb7dfdbd11f98827a3cb1d3a5)
2020-10-27 09:12:01 +02:00
Oran Agra
c80f6219d5 Fix crash in script timeout during AOF loading (#7870)
(cherry picked from commit dc803d25a6f5eb8c41b6afed913cbcd769e4b377)
2020-10-27 09:12:01 +02:00
Rafi Einstein
57027f0c55 Makefile: enable program suffixes via PROG_SUFFIX (#7868)
(cherry picked from commit 2636b760fb062a763ae528800fd998d2913c7cb1)
2020-10-27 09:12:01 +02:00
Rafi Einstein
801c7307fb Makefile: enable program suffixes via PROG_SUFFIX (#7868)
(cherry picked from commit b8187d39fb3eb1cbd2b0346a1e39b68f6ab3029c)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb
38853fd487 Modules: expose real client on conn events.
When REDISMODULE_EVENT_CLIENT_CHANGE events are delivered, modules may
want to mutate the client state (e.g. perform authentication).

This change links the module context with the real client rather than a
fake client for these events.

(cherry picked from commit 4aca4e5f392ad6030150a92a9ef82412072f9622)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb
919580a228 Modules: expose real client on conn events.
When REDISMODULE_EVENT_CLIENT_CHANGE events are delivered, modules may
want to mutate the client state (e.g. perform authentication).

This change links the module context with the real client rather than a
fake client for these events.

(cherry picked from commit 67b43f75e23ba7a3915bc87e7edaa306fd1eee65)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb
0816b8fadd Module API: Fail ineffective auth calls.
The client pointed to by the module context may in some cases be a fake
client. RM_Authenticate*() calls in this case would be ineffective but
appear to succeed, and this change fails them to make it easier to catch
such cases.

(cherry picked from commit 82866776d0c26f17043f9c1b0f0f5f48660e6848)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb
e83d6b0cfa Module API: Fail ineffective auth calls.
The client pointed to by the module context may in some cases be a fake
client. RM_Authenticate*() calls in this case would be ineffective but
appear to succeed, and this change fails them to make it easier to catch
such cases.

(cherry picked from commit cfccfbd6f4ad23c1a9feb44ebb91da9cd2a09734)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb
51a6e1e61a TLS: Do not require CA config if not used. (#7862)
The tls-ca-cert or tls-ca-cert-dir configuration parameters are only
used when Redis needs to authenticate peer certificates, in one of these
scenarios:

1. Incoming clients or replicas, with `tls-auth-clients` enabled.
2. A replica authenticating the master's peer certificate.
3. Cluster nodes authenticating other nodes when establishing the bus
   protocol connection.

(cherry picked from commit 3bd9d0cc85d4ef8f4cc2789e9ab27e5557471409)
2020-10-27 09:12:01 +02:00
Yossi Gottlieb
cb070accb4 TLS: Do not require CA config if not used. (#7862)
The tls-ca-cert or tls-ca-cert-dir configuration parameters are only
used when Redis needs to authenticate peer certificates, in one of these
scenarios:

1. Incoming clients or replicas, with `tls-auth-clients` enabled.
2. A replica authenticating the master's peer certificate.
3. Cluster nodes authenticating other nodes when establishing the bus
   protocol connection.

(cherry picked from commit 1591e3479d46e7e21a98ae685fab2ccab076d094)
2020-10-27 09:12:01 +02:00
Oran Agra
c7cae0df77 warning: comparison between signed and unsigned integer in 32bit build (#7838)
(cherry picked from commit c11bda25fd2959523cb1e87af5b366cc451dbd04)
2020-10-27 09:12:01 +02:00
Oran Agra
9ce6fc7322 warning: comparison between signed and unsigned integer in 32bit build (#7838)
(cherry picked from commit ef33252c434ff25991ff75e2c7e4646bc9ad5ff7)
2020-10-27 09:12:01 +02:00
David CARLIER
4da8211063 Add support for Haiku OS (#7435)
(cherry picked from commit d535a5061ccd561d0c132b2e97b56a3bd252fde9)
2020-10-27 09:12:01 +02:00
David CARLIER
a7b9cfbe98 Add support for Haiku OS (#7435)
(cherry picked from commit f971a5d8ed58547f01325611c0189745a904c9cc)
2020-10-27 09:12:01 +02:00
Gavrie Philipson
c6d6646567 Fix typo in module API docs (#7861)
(cherry picked from commit ce5efb444b203536335ca6dd5d34cb57425b55be)
2020-10-27 09:12:01 +02:00
Gavrie Philipson
219bab2d85 Fix typo in module API docs (#7861)
(cherry picked from commit 49383a4af74bbcca1c194fca458198412ff1820c)
2020-10-27 09:12:01 +02:00
David CARLIER
58a7774ca4 getting rss size implementation for netbsd (#7293)
(cherry picked from commit 520c3b26c3fce1c86cf0c70961acd0515c8cb498)
2020-10-27 09:12:01 +02:00
David CARLIER
d51bebd4d7 getting rss size implementation for netbsd (#7293)
(cherry picked from commit ce8bfc56ad002a3b276249d62038fae4488eae61)
2020-10-27 09:12:01 +02:00
caozb
5ed795f025 ignore slaveof no one in redis.conf (#7842)
when slaveof config is "no one", reset any pre-existing config and resume.

also solve a memory leak if slaveof appears twice.
and fail loading if port number is out of range or not an integer.

Co-authored-by: caozhengbin <caozb@yidingyun.com>
Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 01694608cb4e39a6ec7970d24b21ab33b7347e31)
2020-10-27 09:12:01 +02:00
caozb
63075b81e6 ignore slaveof no one in redis.conf (#7842)
when slaveof config is "no one", reset any pre-existing config and resume.

also solve a memory leak if slaveof appears twice.
and fail loading if port number is out of range or not an integer.

Co-authored-by: caozhengbin <caozb@yidingyun.com>
Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit a295770e32b4bd71ff560c5ec7bc5c0ad12bf068)
2020-10-27 09:12:01 +02:00
Wang Yuan
a6f8745127 Don't support Gopher if enable io threads to read queries (#7851)
There's currently an issue with IO threads and gopher (issuing lookupKey from within the thread).
simply fix is to just not support it for now.

(cherry picked from commit 9bdef76f8e3bbfaacf0962ab1ceded1bafa80bda)
2020-10-27 09:12:01 +02:00
Wang Yuan
9418083770 Don't support Gopher if enable io threads to read queries (#7851)
There's currently an issue with IO threads and gopher (issuing lookupKey from within the thread).
simply fix is to just not support it for now.

(cherry picked from commit c9f00bcce2ce7a59a815642674a12c940bbe2207)
2020-10-27 09:12:01 +02:00
Wang Yuan
9042852ea1 Set 'loading' and 'shutdown_asap' to volatile sig_atomic_t type (#7845)
We may access and modify these two variables in signal handler function,
to guarantee them async-signal-safe, so we should set them to volatile
sig_atomic_t type.

It doesn't look like this could have caused any real issue, and it seems that
signals are handled in main thread on most platforms. But we want to follow C
and POSIX standard in signal handler function.

(cherry picked from commit 917043fa438d9bbe9a80fb838fcfd33a7e390952)
2020-10-27 09:12:01 +02:00
Wang Yuan
5d1ac2df64 Set 'loading' and 'shutdown_asap' to volatile sig_atomic_t type (#7845)
We may access and modify these two variables in signal handler function,
to guarantee them async-signal-safe, so we should set them to volatile
sig_atomic_t type.

It doesn't look like this could have caused any real issue, and it seems that
signals are handled in main thread on most platforms. But we want to follow C
and POSIX standard in signal handler function.

(cherry picked from commit f1863a1fe760610cebfd1c121623a3c12a79d600)
2020-10-27 09:12:01 +02:00
Uri Shachar
10be3d96d8 Fix config rewrite file handling to make it really atomic (#7824)
Make sure we handle short writes correctly, sync to disk after writing  and use
rename to make sure the replacement is actually atomic.
In any case of failure old configuration will remain in place.

Also, add some additional logging to make it easier to diagnose rewrite problems.

(cherry picked from commit 8dbe91f0316f08d785bad1e8e28f1c13ddfbef2c)
2020-10-27 09:12:01 +02:00
Uri Shachar
90555566ed Fix config rewrite file handling to make it really atomic (#7824)
Make sure we handle short writes correctly, sync to disk after writing  and use
rename to make sure the replacement is actually atomic.
In any case of failure old configuration will remain in place.

Also, add some additional logging to make it easier to diagnose rewrite problems.

(cherry picked from commit c30bd02c9d251c63b49ee77a6fd456fb82ff1382)
2020-10-27 09:12:01 +02:00
WuYunlong
39e1f2e2bd Add fsync to readSyncBulkPayload(). (#7839)
We should sync temp DB file before renaming as rdb_fsync_range does not use
flag `SYNC_FILE_RANGE_WAIT_AFTER`.

Refer to `Linux Programmer's Manual`:
SYNC_FILE_RANGE_WAIT_AFTER
    Wait upon write-out of all pages in the range after performing any write.

(cherry picked from commit d119448881655a1529eb6d7d7e78af5f15132536)
2020-10-27 09:12:01 +02:00
WuYunlong
bb7e00b699 Add fsync to readSyncBulkPayload(). (#7839)
We should sync temp DB file before renaming as rdb_fsync_range does not use
flag `SYNC_FILE_RANGE_WAIT_AFTER`.

Refer to `Linux Programmer's Manual`:
SYNC_FILE_RANGE_WAIT_AFTER
    Wait upon write-out of all pages in the range after performing any write.

(cherry picked from commit 0d62caab2113fc12077aadd469e80dd19ca78db2)
2020-10-27 09:12:01 +02:00
Wen Hui
ac867bfb6a rdb.c: handle fclose error case differently to avoid double fclose (#7307)
When fclose would fail, the previous implementation would have attempted to do fclose again
this can in theory lead to segfault.

other changes:
check for non-zero return value as failure rather than a specific error code.
this doesn't fix a real bug, just a minor cleanup.

(cherry picked from commit c67656fa3541376590fe9a9b146ad5641cb861aa)
2020-10-27 09:12:01 +02:00
Wen Hui
faa431c98d rdb.c: handle fclose error case differently to avoid double fclose (#7307)
When fclose would fail, the previous implementation would have attempted to do fclose again
this can in theory lead to segfault.

other changes:
check for non-zero return value as failure rather than a specific error code.
this doesn't fix a real bug, just a minor cleanup.

(cherry picked from commit 323029baa6958781ffae5da331dfc918d66a7117)
2020-10-27 09:12:01 +02:00
Wang Yuan
1c4a99c9ec Don't write replies if close the client ASAP (#7202)
Before this commit, we would have continued to add replies to the reply buffer even if client
output buffer limit is reached, so the used memory would keep increasing over the configured limit.
What's more, we shouldn’t write any reply to the client if it is set 'CLIENT_CLOSE_ASAP' flag
because that doesn't conform to its definition and we will close all clients flagged with
'CLIENT_CLOSE_ASAP' in ‘beforeSleep’.

Because of code execution order, before this, we may firstly write to part of the replies to
the socket before disconnecting it, but in fact, we may can’t send the full replies to clients
since OS socket buffer is limited. But this unexpected behavior makes some commands work well,
for instance ACL DELUSER, if the client deletes the current user, we need to send reply to client
and close the connection, but before, we close the client firstly and write the reply to reply
buffer. secondly, we shouldn't do this despite the fact it works well in most cases.

We add a flag 'CLIENT_CLOSE_AFTER_COMMAND' to mark clients, this flag means we will close the
client after executing commands and send all entire replies, so that we can write replies to
reply buffer during executing commands, send replies to clients, and close them later.

We also fix some implicit problems. If client output buffer limit is enforced in 'multi/exec',
all commands will be executed completely in redis and clients will not read any reply instead of
partial replies. Even more, if the client executes 'ACL deluser' the using user in 'multi/exec',
it will not read the replies after 'ACL deluser' just like before executing 'client kill' itself
in 'multi/exec'.

We added some tests for output buffer limit breach during multi-exec and using a pipeline of
many small commands rather than one with big response.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 3085577c095a0f3b1261f6dbf016d7701aadab46)
2020-10-27 09:12:01 +02:00
Wang Yuan
757ad7cdf2 Don't write replies if close the client ASAP (#7202)
Before this commit, we would have continued to add replies to the reply buffer even if client
output buffer limit is reached, so the used memory would keep increasing over the configured limit.
What's more, we shouldn’t write any reply to the client if it is set 'CLIENT_CLOSE_ASAP' flag
because that doesn't conform to its definition and we will close all clients flagged with
'CLIENT_CLOSE_ASAP' in ‘beforeSleep’.

Because of code execution order, before this, we may firstly write to part of the replies to
the socket before disconnecting it, but in fact, we may can’t send the full replies to clients
since OS socket buffer is limited. But this unexpected behavior makes some commands work well,
for instance ACL DELUSER, if the client deletes the current user, we need to send reply to client
and close the connection, but before, we close the client firstly and write the reply to reply
buffer. secondly, we shouldn't do this despite the fact it works well in most cases.

We add a flag 'CLIENT_CLOSE_AFTER_COMMAND' to mark clients, this flag means we will close the
client after executing commands and send all entire replies, so that we can write replies to
reply buffer during executing commands, send replies to clients, and close them later.

We also fix some implicit problems. If client output buffer limit is enforced in 'multi/exec',
all commands will be executed completely in redis and clients will not read any reply instead of
partial replies. Even more, if the client executes 'ACL deluser' the using user in 'multi/exec',
it will not read the replies after 'ACL deluser' just like before executing 'client kill' itself
in 'multi/exec'.

We added some tests for output buffer limit breach during multi-exec and using a pipeline of
many small commands rather than one with big response.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 57709c4bc663ddcb9313777c551a92dabf07095e)
2020-10-27 09:12:01 +02:00
Guy Korland
66a13267c7 Fix RedisModule_HashGet examples (#6697)
(cherry picked from commit 04945e0e6d5aadd9fb5a7b47d947d759073af51a)
2020-10-27 09:12:01 +02:00
Guy Korland
31491202aa Fix RedisModule_HashGet examples (#6697)
(cherry picked from commit b464afb9e2c16277a5cf62cf1290c8e2ad4b0aa1)
2020-10-27 09:12:01 +02:00
Oran Agra
7ab8961c6d fix recently broken TLS build error, and add coverage for CI (#7833)
(cherry picked from commit 270fcb80bf8c5d8458d60d3a494f422d12e1dfaf)
2020-10-27 09:12:01 +02:00
Oran Agra
26c1c60187 fix recently broken TLS build error, and add coverage for CI (#7833)
(cherry picked from commit a735bf5c2a8a3d3d18c3a7e9cc728768c2086e89)
2020-10-27 09:12:01 +02:00
David CARLIER
06c8f03ba1 Further NetBSD update and build fixes. (#7831)
mainly backtrace and register dump support.

(cherry picked from commit 6bc28d99a3a24c31c44e134b12a502441266e8bc)
2020-10-27 09:12:01 +02:00