604 Commits

Author SHA1 Message Date
Muhammad Zahalqa
e25ec37484 fixes for robj_sharedptr
1. fix cases where null pointer might be accessed
2. make assignmnet op safe
3. make operator bool explicit (safe bool idiom)
4. make comparison operators symetric

fix robj_sharedptr use in rdb.cpp


Former-commit-id: ede524c0647c0875f1071978f26ff785c8d1183e
2020-06-24 23:18:27 -04:00
John Sully
68bf5a04a0 Unify beforeSleep handling
Former-commit-id: 1cb48c7bf6a7e91e728a677902a7bfc64fe80dd6
2020-05-29 17:44:55 -04:00
John Sully
ed2e0e66f6 Merge tag '6.0.4' into unstable
Redis 6.0.4.


Former-commit-id: 9c31ac7925edba187e527f506e5e992946bd38a6
2020-05-29 00:57:07 -04:00
antirez
84117d13b7 Replication: showLatestBacklog() refactored out. 2020-05-28 10:09:51 +02:00
antirez
911c579b68 Remove the meaningful offset feature.
After a closer look, the Redis core devleopers all believe that this was
too fragile, caused many bugs that we didn't expect and that were very
hard to track. Better to find an alternative solution that is simpler.
2020-05-28 10:09:51 +02:00
John Sully
ef4284c439 Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable
Former-commit-id: 1449c8b9fe647288da7de0ff10cc68ada4be8f92
2020-05-26 01:29:08 -04:00
John Sully
5b44b62854 Fix client tracking, also ensure tracking tests are enabled
Former-commit-id: 1938af27f50f9686dc98b4839fb439cc03b4a250
2020-05-26 01:28:52 -04:00
antirez
8a4e01f2bc Make disconnectSlaves() synchronous in the base case.
Otherwise we run into that:

Backtrace:
src/redis-server 127.0.0.1:21322(logStackTrace+0x45)[0x479035]
src/redis-server 127.0.0.1:21322(sigsegvHandler+0xb9)[0x4797f9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fd373c5e390]
src/redis-server 127.0.0.1:21322(_serverAssert+0x6a)[0x47660a]
src/redis-server 127.0.0.1:21322(freeReplicationBacklog+0x42)[0x451282]
src/redis-server 127.0.0.1:21322[0x4552d4]
src/redis-server 127.0.0.1:21322[0x4c5593]
src/redis-server 127.0.0.1:21322(aeProcessEvents+0x2e6)[0x42e786]
src/redis-server 127.0.0.1:21322(aeMain+0x1d)[0x42eb0d]
src/redis-server 127.0.0.1:21322(main+0x4c5)[0x42b145]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fd3738a3830]
src/redis-server 127.0.0.1:21322(_start+0x29)[0x42b409]

Since we disconnect all the replicas and free the replication backlog in
certain replication paths, and the code that will free the replication
backlog expects that no replica is connected.

However we still need to free the replicas asynchronously in certain
cases, as documented in the top comment of disconnectSlaves().
2020-05-25 12:08:01 +02:00
Maxime de Roucy
c0f60008cb acl: @replication command group
containing mandatory commands for replication (used by masteruser user)


Former-commit-id: 123bc125cfe7b30fdeef833759a33ccc854b5c51
2020-05-25 02:35:22 -04:00
John Sully
845027c291 Enable TLS connections
Former-commit-id: d05da0fabdfeb7eadce6546c7c1d85739b2794d7
2020-05-24 19:57:16 -04:00
John Sully
7630b63f06 Hold the AE lock until we process the repl backlog after a command
Former-commit-id: 4893eedacbf5f9210d02361ed07b9beee0c9f655
2020-05-24 11:19:23 -04:00
John Sully
0d8c7c7182 Add standardized way to post client dependent functions
Former-commit-id: fb50163b47cf660911dc7f67809c15ba1394613a
2020-05-24 02:46:39 -04:00
John Sully
2ea5bf4f55 Incorrect memory order on weak ordered architectures
Former-commit-id: 90162da1a6c025d148a0d1761ae4d5fbc9bfc0ef
2020-05-24 01:57:18 -04:00
John Sully
fa0be83fd9 Merge tag '6.0.2' into unstable
Redis 6.0.2


Former-commit-id: a010e4a4b2cc2bcad1cb14604b7ebc596c35b05e
2020-05-22 16:45:18 -04:00
John Sully
c03e9a3e2c Merge commit 'e834acb91c89d083d0075e320dea6ad7188f2d0d' into unstable
Former-commit-id: 817a11ff110772893eda0675912bbb0cfc1fca74
2020-05-22 15:56:35 -04:00
John Sully
193d7c76cb Fix bad merge in CI.yml
Former-commit-id: 6311d709c39b3bacaeab77b18033010f1b548f81
2020-05-21 22:09:06 -04:00
John Sully
e245fdbb89 Merge commit '97e58ee026675e70fbd8843f7a86e98f53a3c791' into unstable
Former-commit-id: 8ab77465dbb3c0b1f859f24cdbb461937516eb6a
2020-05-21 19:37:42 -04:00
John Sully
ccedb2fa73 Merge commit 'd7b07d3ded06b4cd843baffd3a6d33dd96efd401' into unstable
Former-commit-id: 49784c8122e827bd9de86bbae4d88c313400e86e
2020-05-21 18:48:49 -04:00
John Sully
8377df8330 Merge commit '87924d673138531cbaf606015ea7b6a9e3ae2465' into unstable
Former-commit-id: 3e03f308b564cd94f4a6407c80792d080e0f83c5
2020-05-21 17:55:09 -04:00
John Sully
327d543f2c Merge commit 'c5d805f87771581d3f6b29861ed2062c0ae2a688' into unstable
Former-commit-id: 95cecb0229af0278cf614ffd746ba829ae7c897c
2020-05-21 17:45:15 -04:00
John Sully
4246199553 Merge commit '7cb94fd6cc9e1ad106964171023457ae3ff0a40b' into unstable
Former-commit-id: 7676f5b15f24a044257250b8891d23b14642da48
2020-05-21 17:36:53 -04:00
antirez
22a6d152f3 Cache master without checking of deferred close flags.
The context is issue #7205: since the introduction of threaded I/O we close
clients asynchronously by default from readQueryFromClient(). So we
should no longer prevent the caching of the master client, to later
PSYNC incrementally, if such flags are set. However we also don't want
the master client to be cached with such flags (would be closed
immediately after being restored). And yet we want a way to understand
if a master was closed because of a protocol error, and in that case
prevent the caching.
2020-05-15 22:23:24 +02:00
antirez
9d7e2fef3d Track events processed while blocked globally.
Related to #7234.
2020-05-14 11:29:43 +02:00
John Sully
02311d5c85 Implement keydb.hrename command
Former-commit-id: 21d842b0b0d9a0da44e4618a2c1d4ac26553f17b
2020-05-10 17:04:22 -04:00
Titouan Christophe
1e3555e85c make struct user anonymous (only typedefed)
This works because this struct is never referenced by its name,
but always by its type.

This prevents a conflict with struct user from <sys/user.h>
when compiling against uclibc.

Signed-off-by: Titouan Christophe <titouan.christophe@railnova.eu>
2020-05-08 10:37:36 +02:00
hwware
d45fd94b8a Client Side Caching: Add Tracking Prefix Number Stats in Server Info 2020-05-08 10:37:35 +02:00
zhenwei pi
1a632b6964 Support setcpuaffinity on linux/bsd
Currently, there are several types of threads/child processes of a
redis server. Sometimes we need deeply optimise the performance of
redis, so we would like to isolate threads/processes.

There were some discussion about cpu affinity cases in the issue:
https://github.com/antirez/redis/issues/2863

So implement cpu affinity setting by redis.conf in this patch, then
we can config server_cpulist/bio_cpulist/aof_rewrite_cpulist/
bgsave_cpulist by cpu list.

Examples of cpulist in redis.conf:
server_cpulist 0-7:2      means cpu affinity 0,2,4,6
bio_cpulist 1,3           means cpu affinity 1,3
aof_rewrite_cpulist 8-11  means cpu affinity 8,9,10,11
bgsave_cpulist 1,10-11    means cpu affinity 1,10,11

Test on linux/freebsd, both work fine.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-05-08 10:37:35 +02:00
John Sully
ad3de92c57 use serverAssert() instead of assert() to get callstacks in fastlock
Former-commit-id: 45535e8a6377963dce5b158a9a6e448c5c22a0a8
2020-04-28 22:41:07 -04:00
Oran Agra
58619c1286 Keep track of meaningful replication offset in replicas too
Now both master and replicas keep track of the last replication offset
that contains meaningful data (ignoring the tailing pings), and both
trim that tail from the replication backlog, and the offset with which
they try to use for psync.

the implication is that if someone missed some pings, or even have
excessive pings that the promoted replica has, it'll still be able to
psync (avoid full sync).

the downside (which was already committed) is that replicas running old
code may fail to psync, since the promoted replica trims pings form it's
backlog.

This commit adds a test that reproduces several cases of promotions and
demotions with stale and non-stale pings

Background:
The mearningful offset on the master was added recently to solve a problem were
the master is left all alone, injecting PINGs into it's backlog when no one is
listening and then gets demoted and tries to replicate from a replica that didn't
have any of the PINGs (or at least not the last ones).

however, consider this case:
master A has two replicas (B and C) replicating directly from it.
there's no traffic at all, and also no network issues, just many pings in the
tail of the backlog. now B gets promoted, A becomes a replica of B, and C
remains a replica of A. when A gets demoted, it trims the pings from its
backlog, and successfully replicate from B. however, C is still aware of
these PINGs, when it'll disconnect and re-connect to A, it'll ask for something
that's not in the backlog anymore (since A trimmed the tail of it's backlog),
and be forced to do a full sync (something it didn't have to do before the
meaningful offset fix).

Besides that, the psync2 test was always failing randomly here and there, it
turns out the reason were PINGs. Investigating it shows the following scenario:

cycle 1: redis #1 is master, and all the rest are direct replicas of #1
cycle 2: redis #2 is promoted to master, #1 is a replica of #2 and #3 is replica of #1
now we see that when #1 is demoted it prints:
17339:S 21 Apr 2020 11:16:38.523 * Using the meaningful offset 3929963 instead of 3929977 to exclude the final PINGs (14 bytes difference)
17339:S 21 Apr 2020 11:16:39.391 * Trying a partial resynchronization (request e2b3f8817735fdfe5fa4626766daa938b61419e5:3929964).
17339:S 21 Apr 2020 11:16:39.392 * Successful partial resynchronization with master.
and when #3 connects to the demoted #2, #2 says:
17339:S 21 Apr 2020 11:16:40.084 * Partial resynchronization not accepted: Requested offset for secondary ID was 3929978, but I can reply up to 3929964

so the issue here is that the meaningful offset feature saved the day for the
demoted master (since it needs to sync from a replica that didn't get the last
ping), but it didn't help one of the other replicas which did get the last ping.
2020-04-27 15:52:49 +02:00
John Sully
16fd1ed48e shared pointer comparisons with other pointers
Former-commit-id: d5ede50b040c82e02eb2b82982091bdd0fb7da12
2020-04-24 22:20:26 -04:00
antirez
262da0ba78 LCS -> STRALGO LCS.
STRALGO should be a container for mostly read-only string
algorithms in Redis. The algorithms should have two main
characteristics:

1. They should be non trivial to compute, and often not part of
programming language standard libraries.
2. They should be fast enough that it is a good idea to have optimized C
implementations.

Next thing I would love to see? A small strings compression algorithm.
2020-04-24 16:49:27 +02:00
antirez
f066273907 Tracking: NOLOOP internals implementation. 2020-04-24 10:14:48 +02:00
John Sully
c001ea5b41 Merge branch 'unstable' into redis_6_merge
Former-commit-id: cc9924ffa606200f331b3bf5e1e1a4aa3f2702fa
2020-04-15 23:00:13 -04:00
John Sully
822f64ed2f During AOF reload we can erroneously read incorrect aof_state values, so this variable must be read with the global lock acquired
Former-commit-id: 6ff9d23fd4541a011d754209d9fda3ef3af4a7f9
2020-04-15 22:30:19 -04:00
John Sully
e8270a2f0b Convert variables accessed outside lock to atomics
Former-commit-id: b0796ff5fd7e069a2fadbfd968f7bbb2020edd2d
2020-04-15 22:25:17 -04:00
antirez
97e58ee026 Use the special static refcount for stack objects. 2020-04-15 16:03:16 +02:00
antirez
ec24d65c06 RDB: refactor some RDB loading code into dbAddRDBLoad(). 2020-04-15 16:03:16 +02:00
antirez
a889c94447 incrRefCount(): abort on statically allocated object. 2020-04-15 16:03:16 +02:00
antirez
533fd1fe7b 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-15 16:03:16 +02:00
John Sully
f69c169c04 Merge tag '6.0-rc3' into redis_6_merge
Redis 6.0 RC3.


Former-commit-id: b2cb10de5f39b4d8e1ee19877c2bdaf19eefd9db
2020-04-14 22:56:19 -04:00
John Sully
3e656bcb3f Merge commit '2a820251c8ffba152e00ef7b1ca5e7a477087d33' into redis_6_merge
Former-commit-id: 50768cd242c0360c6e943c57f866789280d30dc0
2020-04-14 22:25:44 -04:00
John Sully
ce54857237 Merge commit '454e12cb8961f21c9dd8502dc82ae6ffd7e22fe0' into redis_6_merge
Former-commit-id: cc3ebbe5194e9744fb84ce490e90ac5fbe7f8716
2020-04-14 22:19:29 -04:00
John Sully
90cbdd5573 Merge commit 'c208956fbe077e8249d2965dec2ea1b9b7588d6d' into redis_6_merge
Former-commit-id: 2825e515504cffcf6000be2e547ab1cbd86441bc
2020-04-14 20:55:29 -04:00
John Sully
68c50ae876 Merge commit '6718d5d37517bd927635649708913affb98f67c9' into redis_6_merge
Former-commit-id: ef1236b6009ebd7b00f6dd2f43df57ad95e51253
2020-04-14 20:19:48 -04:00
John Sully
2c049c16a2 Merge commit '79e8b17d7b44c793d8b22668b8583a297ee1b387' into redis_6_merge
Former-commit-id: 28cbed1d13961c5568f2bdc50c6a23107d3434d0
2020-04-14 20:09:53 -04:00
John Sully
d48ea996e7 Merge commit '13fbdf970660b15011c4312f31137e58bbda5b2c' into redis_6_merge
Former-commit-id: cde199a7973ad63317b68f581df607321e12bf46
2020-04-14 19:43:04 -04:00
John Sully
6df76a3bfa Merge commit 'a8e2bbe8f6a3f4833f286cc5049e6b52c87de1a9' into redis_6_merge
Former-commit-id: 5589a0a69ca6f5798b750a6a79f7e9b44d20e136
2020-04-14 19:22:44 -04:00
John Sully
2038fa270a Merge commit '491949ee5bf4ffbfc746ea4ed5a6d673b0e2fb81' into redis_6_merge
Former-commit-id: 09e8fb17cd0889ad17461e48446221b3955f5a8f
2020-04-14 18:44:42 -04:00
antirez
c38bc83f47 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.


Former-commit-id: 5d6e8fe3e3e43162f0c57f580b6e8432274fca30
2020-04-14 17:56:09 -04:00
antirez
f7e8240900 Remove RDB files used for replication in persistence-less instances.
Former-commit-id: b323645227a3e2cc5928e649586221aba508b10d
2020-04-14 17:27:05 -04:00