27289 Commits

Author SHA1 Message Date
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
nitaicaro
e7bae88392 Fixed Tracking test “The other connection is able to get invalidations” (#7871)
PROBLEM:

[$rd1 read] reads invalidation messages one by one, so it's never going to see the second invalidation message produced after INCR b, whether or not it exists. Adding another read will block incase no invalidation message is produced.

FIX:

We switch the order of "INCR a" and "INCR b" - now "INCR b" comes first. We still only read the first invalidation message produces. If an invalidation message is wrongly produces for b - then it will be produced before that of a, since "INCR b" comes before "INCR a".

Co-authored-by: Nitai Caro <caronita@amazon.com>
(cherry picked from commit 94e9b0124e8582912c3771f9828842348490bc38)
2020-10-27 09:12:01 +02:00
nitaicaro
a7b95b7c72 Fixed Tracking test “The other connection is able to get invalidations” (#7871)
PROBLEM:

[$rd1 read] reads invalidation messages one by one, so it's never going to see the second invalidation message produced after INCR b, whether or not it exists. Adding another read will block incase no invalidation message is produced.

FIX:

We switch the order of "INCR a" and "INCR b" - now "INCR b" comes first. We still only read the first invalidation message produces. If an invalidation message is wrongly produces for b - then it will be produced before that of a, since "INCR b" comes before "INCR a".

Co-authored-by: Nitai Caro <caronita@amazon.com>
(cherry picked from commit 8fb89a572892e600146bd933c4f8f99d46a519c7)
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
Oran Agra
0fc601b3dd Fix new obuf-limits tests to work with TLS (#7848)
Also stabilize new shutdown tests on slow machines (valgrind)

(cherry picked from commit d89ae2d7ab3f6d181689b2546f2784b574d9b80e)
2020-10-27 09:12:01 +02:00
Oran Agra
120c6b43e1 Fix new obuf-limits tests to work with TLS (#7848)
Also stabilize new shutdown tests on slow machines (valgrind)

(cherry picked from commit 8aa083bd283963f60c46eb6156e7aacca3c853c3)
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
David CARLIER
2ccbba650c Further NetBSD update and build fixes. (#7831)
mainly backtrace and register dump support.

(cherry picked from commit c3edaa79413bdf908abb56f088217c01f347ecff)
2020-10-27 09:12:01 +02:00
WuYunlong
d3fc736123 Fix redundancy use of semicolon in do-while macros in ziplist.c. (#7832)
this is very dangerous bug, but it looks like it didn't cause any harm.

(cherry picked from commit 00668f782f0d8e987fc2c049c34e100567c0a5c6)
2020-10-27 09:12:01 +02:00
WuYunlong
c73406c2bd Fix redundancy use of semicolon in do-while macros in ziplist.c. (#7832)
this is very dangerous bug, but it looks like it didn't cause any harm.

(cherry picked from commit 63cd4d4e2044059c44a65e2ce424b9ce1fcdbd39)
2020-10-27 09:12:01 +02:00
yixiang
f478a1b6fb Fix connGetSocketError usage (#7811)
(cherry picked from commit 4e70e49d2bdaa477d9436a394f8626a1cc6e94af)
2020-10-27 09:12:01 +02:00
yixiang
c1423c016c Fix connGetSocketError usage (#7811)
(cherry picked from commit b96c3595af817721fc838746b859249bf9cf3aaf)
2020-10-27 09:12:01 +02:00