12903 Commits

Author SHA1 Message Date
Oran Agra
47364bce69 Change THP warning to use madvise rather than never (#7771)
completes b2419c31c166bd2d73f7af3d089859795c0e3506

(cherry picked from commit 1461f02deb65585bb47c4d50d68ef733edfba6f9)
2020-09-10 14:09:00 +03:00
Itamar Haber
3cd6c26056 Documents RM_Call's fmt (#5448)
Improve RM_Call inline documentation about the fmt argument
so that we don't completely depend on the web docs.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit ce15620dc17ebad94cd03cb4ee779fdd4e99b212)
2020-09-10 14:09:00 +03:00
Jan-Erik Rediger
8b0d797ecd Check that THP is not set to always (madvise is ok) (#4001)
THP can also be set to madvise, in which case it shouldn't cause
problems for Redis since redis (or the allocator) doesn't use madvise
to activate it.

(cherry picked from commit b2419c31c166bd2d73f7af3d089859795c0e3506)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb
3c8b394511 Tests: clean up stale .cli files. (#7768)
(cherry picked from commit 918abd7276afcb994f2d3f8a86a0708993420e37)
2020-09-10 14:09:00 +03:00
Eran Liberty
84ba2ec82b Allow exec with read commands on readonly replica in cluster (#7766)
There was a bug. Although cluster replicas would allow read commands,
they would not allow a MULTI-EXEC that's composed solely of read commands.
Adds tests for coverage.

Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: Eran Liberty <eranl@amazon.com>
(cherry picked from commit b120366d48d9e488a406965773e64f29ba2946f7)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb
cf3375bf7c Fix CONFIG REWRITE of oom-score-adj-values. (#7761)
(cherry picked from commit 750acf3a457053ad9f57a263baa84ec68e0ae145)
2020-09-10 14:09:00 +03:00
Oran Agra
643d3e0b79 handle cur_test for nested tests
if there are nested tests and nested servers, we need to restore the
previous value of cur_test when a test exist.

example:
```
test{test 1} {
	start_server {
		test{test 1.1 - master only} {
		}
		start_server {
		    test{test 1.2 - with replication} {
            }
		}
	}
}
```
when `test 1.1 - master only exists`, we're still inside `test 1`

(cherry picked from commit 0a1e7341935dbca4bae582de1a4a26d5ed4c652d)
2020-09-10 14:09:00 +03:00
Oran Agra
874c3a9978 Add daily CI for MacOS (#7759)
(cherry picked from commit 5496b4a7cd9f04fb28ab5c6d903f1b59a9c0842c)
2020-09-10 14:09:00 +03:00
bodong.ybd
781e50d41f Tests: Some fixes for macOS
1) cur_test: when restart_server, "no such variable" error occurs
  ./runtest --single integration/rdb
  test {client freed during loading}
      SET ::cur_test
      restart_server
        kill_server
          test "Check for memory leaks (pid $pid)"
          SET ::cur_test
          UNSET ::cur_test
      UNSET ::cur_test // This global variable has been unset.

2) `ps --ppid` not available on macOS platform, can be replaced with
`pgrep -P pid`.

(cherry picked from commit f22fa9594d536cb53f83ed8e508c03d4278778b0)
2020-09-10 14:09:00 +03:00
Oran Agra
57dbd6e90d Fix cluster consistency-check test (#7754)
This test was failing from time to time see discussion at the bottom of #7635
This was probably due to timing, the DEBUG SLEEP executed by redis-cli
didn't sleep for enough time.

This commit changes:
1) use SET-ACTIVE-EXPIRE instead of DEBUG SLEEP
2) reduce many `after` sleeps with retry loops to speed up the test.
3) add many comment explaining the different steps of the test and
   it's purpose.
4) config appendonly before populating the volatile keys, so that they'll
   be part of the AOF command stream rather than the preamble RDB portion.

other complications: recently kill_instance switched from SIGKILL to
SIGTERM, and this would sometimes fail since there was an AOFRW running
in the background. now we wait for it to end before attempting the kill.

(cherry picked from commit b491d477c3062d1fb064a794d74643c82d1c4adc)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb
e9fef49e12 Tests: fix unmonitored servers. (#7756)
There is an inherent race condition in port allocation for spawned
servers. If a server fails to start because a port is taken, a new port
is allocated. This fixes a problem where the logs are not truncated and
as a result a large number of unmonitored servers are started.

(cherry picked from commit 2df4cb93acabf10bb0ff39c12030791b0947e719)
2020-09-10 14:09:00 +03:00
Oran Agra
a227bc8053 fix broken cluster/sentinel tests by recent commit (#7752)
2b998de46 added a file for stderr to keep valgrind log but i forgot to
add a similar thing when valgrind isn't being used.
the result is that `glob */err.txt` fails.

(cherry picked from commit 42ba7a1b75aa100ba99d2024420bc658439452fb)
2020-09-10 14:09:00 +03:00
Oran Agra
d410dc3162 Improve valgrind support for cluster tests (#7725)
- redirect valgrind reports to a dedicated file rather than console
- try to avoid killing instances with SIGKILL so that we get the memory
  leak report (killing with SIGTERM before resorting to SIGKILL)
- search for valgrind reports when done, print them and fail the tests
- add --dont-clean option to keep the logs on exit
- fix exit error code when crash is found (would have exited with 0)

changes that affect the normal redis test suite:
- refactor check_valgrind_errors into two functions one to search and
  one to report
- move the search half into util.tcl to serve the cluster tests too
- ignore "address range perms" valgrind warnings which seem non relevant.

(cherry picked from commit 2b998de46078c172c6b19ac3b779318e7992c60a)
2020-09-10 14:09:00 +03:00
Oran Agra
41c7c7919c test infra - add durable mode to work around test suite crashing
in some cases a command that returns an error possibly due to a timing
issue causes the tcl code to crash and thus prevents the rest of the
tests from running. this adds an option to make the test proceed despite
the crash.
maybe it should be the default mode some day.

(cherry picked from commit fe5da2e60d8d6d907062f4789673fbe06fa8773e)
2020-09-10 14:09:00 +03:00
Oran Agra
db6c763d8b test infra - wait_done_loading
reduce code duplication in aof.tcl.
move creation of clients into the test so that it can be skipped

(cherry picked from commit 1b7ba44e7917082ac6d5523666d3b4ab210dfbad)
2020-09-10 14:09:00 +03:00
Oran Agra
72d6f966ac test infra - flushall between tests in external mode
(cherry picked from commit b65e5aca86b9c2d24b96abc8414a45f9907b6f7d)
2020-09-10 14:09:00 +03:00
Oran Agra
28e074608c test infra - improve test skipping ability
- skip full units
- skip a single test (not just a list of tests)
- when skipping tag, skip spinning up servers, not just the tests
- skip tags when running against an external server too
- allow using multiple tags (split them)

(cherry picked from commit 677d14c2137ab50fa25c8163d20b14bc563261c7)
2020-09-10 14:09:00 +03:00
Oran Agra
5b8de5b7f2 test infra - reduce disk space usage
this is important when running a test with --loop

(cherry picked from commit e3e69c25fd05b608f5ea8d612bc0e377922a6115)
2020-09-10 14:09:00 +03:00
Oran Agra
bce350c666 test infra - write test name to logfile
(cherry picked from commit 9d527d076b17851b87bc95aa34cca8fa5a91d41b)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb
332aa2f919 redis-cli: fix writeConn() buffer handling. (#7749)
Fix issues with writeConn() which resulted with corruption of the stream by leaving an extra byte in the buffer. The trigger for this is partial writes or write errors which were not experienced on Linux but reported on macOS.

(cherry picked from commit 58e5feb3f49c50b9c18f38fd8f6cad2317c02265)
2020-09-10 14:09:00 +03:00
Oran Agra
e4db67ea57 Print server startup messages after daemonization (#7743)
When redis isn't configured to have a log file, having these prints
before damonization puts them in the calling process stdout rather than
/dev/null

(cherry picked from commit 8b0747d65734ba1128da7479f8b961e530b82916)
2020-09-10 14:09:00 +03:00
Thandayuthapani
b983015dd4 Add masters/replicas options to redis-cli --cluster call command (#6491)
* Add master/slave option in --cluster call command

* Update src/redis-cli.c

* Update src/redis-cli.c

Co-authored-by: Itamar Haber <itamar@redislabs.com>
(cherry picked from commit f22f64f0db82cce666714808a9c994304f97904a)
2020-09-10 14:09:00 +03:00
Oran Agra
9b718d41f0 fix README about BUILD_WITH_SYSTEMD usage (#7739)
BUILD_WITH_SYSTEMD is an internal variable. Users should use USE_SYSTEMD=yes.

(cherry picked from commit 747b4004eaf49b40a25f9b4f78f57b6328f015c7)
2020-09-10 14:09:00 +03:00
Yossi Gottlieb
da33a18588 Fix double-make issue with make && make install. (#7734)
All user-supplied variables that affect the build should be explicitly
persisted.

Fixes #7254

(cherry picked from commit b35d6e5cffb895ab6cbbd9e5e56ef00299b1359e)
2020-09-10 14:09:00 +03:00
John Sully
855753ebb3 Fix whitespace
Former-commit-id: d47aeb1fc8a6804a44035253ad87478b817605cf
2020-09-07 03:35:46 +00:00
John Sully
b6d8a5938d Dramatically improve perf by blocking commands
Former-commit-id: e47584b286c41cf0783fe014ac8b6ec187564ade
2020-09-07 00:49:53 +00:00
Oran Agra
dbea5f7a8d Redis 6.0.7 2020-09-01 09:27:58 +03:00
Oran Agra
4bb40a9688 Reduce the probability of failure when start redis in runtest-cluster #7554 (#7635)
When runtest-cluster, at first, we need to create a cluster use spawn_instance,
a port which is not used is choosen, however sometimes we can't run server on
the port. possibley due to a race with another process taking it first.
such as redis/redis/runs/896537490. It may be due to the machine problem or
In order to reduce the probability of failure when start redis in
runtest-cluster, we attemp to use another port when find server do not start up.

Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: yanhui13 <yanhui13@meituan.com>
(cherry picked from commit e2d64485b8262971776fb1be803c7296c98d1572)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb
d2532d1335 Backport Lua 5.2.2 stack overflow fix. (#7733)
This fixes the issue described in CVE-2014-5461. At this time we cannot
confirm that the original issue has a real impact on Redis, but it is
included as an extra safety measure.

(cherry picked from commit d75ad774a92bd7de0b9448be3d622d7a13b7af27)
2020-09-01 09:27:58 +03:00
Leoš Literák
00d0d870d2 Update README.md with instructions how to build with systemd support (#7730)
#7728 - update instructions for systemd support

(cherry picked from commit 571571ca192ec0b7cc66ca61cd6794dcb6a9d8bc)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb
f38e2802b6 Fix oom-score-adj on older distros. (#7724)
Don't assume `ps` handles `-h` to display output without headers and
manually trim headers line from output.

(cherry picked from commit b61b663895f16d9f559a14c408c225062254a57b)
2020-09-01 09:27:58 +03:00
Wang Yuan
1b100a167a Fix wrong format specifiers of 'sdscatfmt' for the INFO command (#7706)
unlike printf, sdscatfmt doesn't take %d

(cherry picked from commit 43af28f5b487370bd3d65d00be93c4a23ee42fa7)
2020-09-01 09:27:58 +03:00
Wen Hui
d4e1c88052 fix make warnings (#7692)
(cherry picked from commit e61adc0d897074d8c2ca8e0f7bf08fa2985d9b01)
2020-09-01 09:27:58 +03:00
Nathan Scott
2c0c5a809c Annotate module API functions in redismodule.h for use with -fno-common (#6900)
In order to keep the redismodule.h self-contained but still usable with
gcc v10 and later, annotate each API function tentative definition with
the __common__ attribute.  This avoids the 'multiple definition' errors
modules will otherwise see for all API functions at link time.

Further details at gcc.gnu.org/gcc-10/porting_to.html

Turn the existing __attribute__ ((unused)), ((__common__)) and ((print))
annotations into conditional macros for any compilers not accepting this
syntax.  These macros only expand to API annotations under gcc.

Provide a pre- and post- macro for every API function, so that they can
be defined differently by the file that includes redismodule.h.

Removing REDISMODULE_API_FUNC in the interest of keeping the function
declarations readable.

Co-authored-by: Yossi Gottlieb <yossigo@gmail.com>
Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 11cd983d58199b6ac7fa54049734457bd767a0b5)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb
f6d04d01b9 Add oom-score-adj configuration option to control Linux OOM killer. (#1690)
Add Linux kernel OOM killer control option.

This adds the ability to control the Linux OOM killer oom_score_adj
parameter for all Redis processes, depending on the process role (i.e.
master, replica, background child).

A oom-score-adj global boolean flag control this feature. In addition,
specific values can be configured using oom-score-adj-values if
additional tuning is required.

(cherry picked from commit 2530dc0ebd8be8d792f4673073401377cd5bdc42)
2020-09-01 09:27:58 +03:00
Meir Shpilraien (Spielrein)
2fc915f509 see #7544, added RedisModule_HoldString api. (#7577)
Added RedisModule_HoldString that either returns a
shallow copy of the given String (by increasing
the String ref count) or a new deep copy of String
in case its not possible to get a shallow copy.

Co-authored-by: Itamar Haber <itamar@redislabs.com>
(cherry picked from commit 3f494cc49d25929f27fa75a78d9921a9dee771f2)
2020-09-01 09:27:58 +03:00
ShooterIT
e3cfc92180 [Redis-benchmark] Remove zrem test, add zpopmin test
(cherry picked from commit 6a06a5a597b349be4cf587e59613bbf4cd2f2c43)
2020-09-01 09:27:58 +03:00
ShooterIT
7fcf29e615 [Redis-benchmark] Support zset type
(cherry picked from commit e5a50ed3c49c211b413d92b1f45f950c830c58c0)
2020-09-01 09:27:58 +03:00
Arun Ranganathan
e81bac32fd Show threading configuration in INFO output (#7446)
Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit f6cad30bb69b2ad35bb0a870077fac2d4605d727)
2020-09-01 09:27:58 +03:00
Meir Shpilraien (Spielrein)
2257f38b68 This PR introduces a new loaded keyspace event (#7536)
Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: Itamar Haber <itamar@redislabs.com>
(cherry picked from commit 8d826393191399e132bd9e56fb51ed83223cc5ca)
2020-09-01 09:27:58 +03:00
Oran Agra
2165a78d10 Fix rejectCommand trims newline in shared error objects, hung clients (#7714)
65a3307bc (released in 6.0.6) has a side effect, when processCommand
rejects a command with pre-made shared object error string, it trims the
newlines from the end of the string. if that string is later used with
addReply, the newline will be missing, breaking the protocol, and
leaving the client hung.

It seems that the only scenario which this happens is when replying with
-LOADING to some command, and later using that reply from the CONFIG
SET command (still during loading). this will result in hung client.

Refactoring the code in order to avoid trimming these newlines from
shared string objects, and do the newline trimming only in other cases
where it's needed.

Co-authored-by: Guy Benoish <guy.benoish@redislabs.com>
(cherry picked from commit 9fcd9e191e6f54276688fb7c74e1d5c3c4be9a75)
2020-09-01 09:27:58 +03:00
valentinogeron
e6f6731c66 EXEC with only read commands should not be rejected when OOM (#7696)
If the server gets MULTI command followed by only read
commands, and right before it gets the EXEC it reaches OOM,
the client will get OOM response.

So, from now on, it will get OOM response only if there was
at least one command that was tagged with `use-memory` flag

(cherry picked from commit b7289e912cbe1a011a5569cd67929e83731b9660)
2020-09-01 09:27:58 +03:00
Itamar Haber
5a9a653f3e Expands lazyfree's effort estimate to include Streams (#5794)
Otherwise, it is treated as a single allocation and freed synchronously. The following logic is used for estimating the effort in constant-ish time complexity:

1. Check the number of nodes.
1. Add an allocation for each consumer group registered inside the stream.
1. Check the number of PELs in the first CG, and then add this count times the number of CGs.
1. Check the number of consumers in the first CG, and then add this count times the number of CGs.

(cherry picked from commit 5b0a06af48997794af60dabb58ce4336ef56f73d)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb
ff0846cbb7 Add language servers stuff, test/tls to gitignore. (#7698)
(cherry picked from commit 5449a2a8b54db6a57b564e453c9f7075ebb81f79)
2020-09-01 09:27:58 +03:00
Valentino Geron
3e2ed279fd Assert that setDeferredAggregateLen isn't called with negative value
In case the redis is about to return broken reply we want to crash
with assert so that we are notified about the bug. see #7687.

(cherry picked from commit 8b428cf0f7ce5489fbdf4640a1dd36357f3dc5f0)
2020-09-01 09:27:58 +03:00
Valentino Geron
19ef1f371d Fix LPOS command when RANK is greater than matches
When calling to LPOS command when RANK is higher than matches,
the return value is non valid response. For example:
```
LPUSH l a
:1
LPOS l b RANK 5 COUNT 10
*-4
```
It may break client-side parser.

Now, we count how many replies were replied in the array.
```
LPUSH l a
:1
LPOS l b RANK 5 COUNT 10
*0
```

(cherry picked from commit 9204a9b2c2f6eb59767ab0bddcde62c75e8c20b0)
2020-09-01 09:27:58 +03:00
Yossi Gottlieb
8d79702d8a Tests: fix redis-cli with remote hosts. (#7693)
(cherry picked from commit f80f3f492a0ca56e163899eeca7ad40d67d903be)
2020-09-01 09:27:58 +03:00
huangzhw
6cfcf76e0b RedisModuleEvent_LoadingProgress always at 100% progress (#7685)
It was also using the wrong struct, but luckily RedisModuleFlushInfo and RedisModuleLoadingProgress
are identical.

(cherry picked from commit a3d4d7bf68bf825584b34785ed2b117dd24c1754)
2020-09-01 09:27:58 +03:00
guybe7
c9478a3b4e Modules: Invalidate saved_oparray after use (#7688)
We wanna avoid a chance of someone using the pointer in it after it'll be freed / realloced.

(cherry picked from commit 65c24bd3d436a08a680fa80bf5b3f4f9cf8ef395)
2020-09-01 09:27:58 +03:00
杨博东
113d5ae872 Fix flock cluster config may cause failure to restart after kill -9 (#7674)
After fork, the child process(redis-aof-rewrite) will get the fd opened
by the parent process(redis), when redis killed by kill -9, it will not
graceful exit(call prepareForShutdown()), so redis-aof-rewrite thread may still
alive, the fd(lock) will still be held by redis-aof-rewrite thread, and
redis restart will fail to get lock, means fail to start.

This issue was causing failures in the cluster tests in github actions.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit cbaf3c5bbafd43e009a2d6b38dd0e9fc450a3e12)
2020-09-01 09:27:58 +03:00