792 Commits

Author SHA1 Message Date
John Sully
95ae92a691 Optimize freeMemory by lazy freeing objects
Former-commit-id: cca31ed5ee2f42975f0051cfabf1e88720b3d678
2021-04-21 01:20:13 +00:00
John Sully
5ccaa9265c Don't prefetch when lock contention is low, it increases latency
Former-commit-id: 9b2629f6a20368cec8e55f0d006f3a67c8b770b7
2021-04-12 03:23:49 +00:00
John Sully
69f7a194bc Make prefetch configurable
Former-commit-id: 16996c048042bd3799c8051645bbe7c54137d54c
2021-04-08 19:52:38 +00:00
John Sully
571718f774 Avoid posting unnecessary async tasks
Former-commit-id: 08f63fdfd6c78388bba093ec2edda7d77fc9173e
2021-04-07 17:41:20 +00:00
jsully
c168c8fbbf Merge branch 'flash_read_perf' into 'keydbpro'
Flash read perf

See merge request external-collab/keydb-pro-6!1

Former-commit-id: f6d7277f307b78f079dd99bf532cd26a7b62018d
2021-04-07 06:12:55 +00:00
Cloud User
6601905d8c Make high pri time thread configurable
Former-commit-id: 7e94207765d2166f46792aea0919786f3f30d7b3
2021-04-06 22:39:20 +00:00
jsully
7b61c83b3e Merge branch 'keydbpro' into 'flash_read_perf'
# Conflicts:
#   src/db.cpp
#   src/networking.cpp

Former-commit-id: e16c846b2b9e70f20981172287b19e585f81d73d
2021-04-01 17:25:31 +00:00
John Sully
0b6a66ca55 Fix crash in RDB save
Former-commit-id: b032809b3e978fe571b791179d32ecdc9c067045
2021-03-30 20:49:33 +00:00
John Sully
33197a128d Fix thread safety issues with the cache prefetch logic
Former-commit-id: 4892122fc02109d98684a350bd732a0b08a8c7b4
2021-03-28 20:21:44 +00:00
John Sully
c6fc1bcfe3 Perform GET command inline
Former-commit-id: 5623936d99e334ab103f3dc1541b145c125d0ee8
2021-03-23 03:44:20 +00:00
John Sully
61d548079c Remove snapshot consolidation because its not properly thread safe
Former-commit-id: dcb86d2b92e3ecdb9f914b6f5de9e184cdd23036
2021-03-16 02:37:49 +00:00
John Sully
15e1ee620f Fix TSAN errors in tests
Former-commit-id: 30207d2ab34f175b94f430f97581191343d23f1e
2021-03-16 02:29:24 +00:00
John Sully
902264efb7 Load perf fixes with a storage provider set
Former-commit-id: 861b19de00c75c9167cc25031292284ad1c21893
2021-03-04 07:41:06 +00:00
John Sully
76698beeaf Drastically improve perf when loading an RDB with a storage provider
Former-commit-id: 0133b42d54676e8fac2c5cb006cc87988dced268
2021-03-02 04:16:20 +00:00
John Sully
bbb310f419 Eliminate needless lock
Former-commit-id: 60f972d463f202edb33ff9a25bc2bd3e2558105c
2021-02-26 05:40:56 +00:00
christian
53b7b83af6 Offload updating cached time to dedicated thread
Former-commit-id: 9bfc8a43952481b5b54a7b051d44b8bece4a18dd
2021-02-26 00:50:22 +00:00
John Sully
87fc018415 Implement maxstorage config
Former-commit-id: 79e07859dfec14edf2a39646013e1a82db033d4f
2021-02-19 05:17:41 +00:00
John Sully
c43bb8e8b5 Fix deadlock in storage prefetch
Former-commit-id: 9e6162de08248f7726b97b73aee2f23808ff4e7b
2021-02-12 19:38:57 +00:00
John Sully
ef471e6e53 Enable prefetch with storage providers
Former-commit-id: 21f9c52c446ad1b460a340c3d873839b2355728f
2021-02-11 00:50:21 +00:00
John Sully
078abba316 Merge branch 'unstable' into keydbpro
Former-commit-id: e2140793f2bf565972ada799af73bf4457e2718d
2021-02-08 18:17:09 +00:00
John Sully
495dff1e8c Implement rehash during spinlock
Former-commit-id: f68a26381a35b27948046d46c2c7bcfbdc21143d
2021-02-07 19:11:05 -05:00
John Sully
e2f634aef5 Fix cluster test failure
Former-commit-id: 230fde39882766426d892fd30d0c8349f5cca912
2021-02-07 23:38:25 +00:00
christianEQ
fc83515309 fixed up backup stuff
Former-commit-id: 8a23162c24dc13a4268928c5defd85b0b5249d39
2021-02-04 22:36:32 +00:00
christianEQ
c69b2845fd Merge remote-tracking branch 'opensource/unstable' into keydbpro
Former-commit-id: 5bad058733de2c217340bb9ee48f02b07d754808
2021-02-03 18:10:27 +00:00
christianEQ
19dc63bd3a added severity levels for afterErrorReply
Former-commit-id: fe0f07199353abf6668cd66cd2e21751db5c21d9
2021-01-31 00:12:49 -05:00
christianEQ
5a6f7c395f killMainThread -> killServerThreads
Former-commit-id: 0fea781f8f0218c5475890a395c49bd7e4faa03f
2021-01-28 23:57:19 +00:00
christianEQ
59ffc79765 removed unimplemented killIOThreads function declaration
Former-commit-id: f30f8eba2f0a5cb247478c2104a4f748659a6cf2
2021-01-26 22:27:22 +00:00
christianEQ
8d7142488b fixed server.cpp mentions
Former-commit-id: 7ed2296fc5d10a1c41020558b4bc445953531bdd
2021-01-26 22:22:19 +00:00
christianEQ
c068f2cd3d Merge tag 'tags/6.0.10' into redismerge_2021-01-20
Former-commit-id: dadce055f897cee83946c2d3e5cbb76341b94230
2021-01-26 21:43:09 +00:00
christianEQ
ab80e23152 changed loading process config types to be consistent across environments
Former-commit-id: d2867580aba70bbfa703578cdb40093a4e1a7147
2021-01-14 21:12:36 -05:00
christianEQ
28a0cdc572 added config option for loading callback interval keys
Former-commit-id: 9f7ed0b2327924563668105ead09f52833902d0b
2021-01-14 13:06:57 -05:00
Yang Bodong
356e8f1afb Swapdb should make transaction fail if there is any client watching keys (#8239)
This PR not only fixes the problem that swapdb does not make the
transaction fail, but also optimizes the FLUSHALL and FLUSHDB command to
set the CLIENT_DIRTY_CAS flag to avoid unnecessary traversal of clients.

FLUSHDB was changed to first iterate on all watched keys, and then on the
clients watching each key.
Instead of iterating though all clients, and for each iterate on watched keys.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit f571f8467cecb69a1c7c6810a445addfb802d85a)
2021-01-12 16:25:37 +02:00
George Prekas
fecbb48519 Add check for the MADV_FREE/fork arm64 Linux kernel bug (#8224)
Older arm64 Linux kernels have a bug that could lead to data corruption during
background save under the following scenario:

1) jemalloc uses MADV_FREE on a page,
2) jemalloc reuses and writes the page,
3) Redis forks the background save process, and
4) Linux performs page reclamation.

Under these conditions, Linux will reclaim the page wrongfully and the
background save process will read zeros when it tries to read the page.

The bug has been fixed in Linux with commit:
ff1712f953e27f0b0718762ec17d0adb15c9fd0b ("arm64: pgtable: Ensure dirty bit is
preserved across pte_wrprotect()")

This Commit adds an ignore-warnings config, when not found, redis will
print a warning and exit on startup (default behavior).

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 75bbf56d37d1134cc9c4f36900a4a623604776a5)

in 6.0 this warning is ignored by default in order to avoid adding
regression, specifically for deployments that don't need persistence or
replication
2021-01-12 16:25:37 +02:00
Wang Yuan
f5d6057cbb Backup keys to slots map and restore when fail to sync if diskless-load type is swapdb in cluster mode (#8108)
When replica diskless-load type is swapdb in cluster mode, we didn't backup
keys to slots map, so we will lose keys to slots map if fail to sync.
Now we backup keys to slots map at first, and restore it properly when fail.

This commit includes a refactory/cleanup of the backups mechanism (moving it to db.c and re-structuring it a bit).

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit 10712afaf3e7f2ea859622fa5b27c96ee8f478c5)
2021-01-12 16:25:37 +02:00
Oran Agra
878d8476e5 Fix oom-score-adj-values range, abs options, and bug when used in config file (#8046)
Fix: When oom-score-adj-values is provided in the config file after
oom-score-adj yes, it'll take an immediate action, before
readOOMScoreAdj was acquired, resulting in an error (out of range score
due to uninitialized value. delay the reaction the real call is made by
main().

Since the values are clamped to -1000..1000, and they're
applied as an offset from the value at startup (which may be -1000), we
need to allow the offsets to reach to +2000 so that a value of +1000 is
achievable in case the value at startup was -1000.

Adding an option for absolute values rather than relative ones.

(cherry picked from commit f08fd95c6686467ecd46116dab150d47563aed1c)
2021-01-12 16:25:37 +02:00
guybe7
02236725af EXISTS should not alter LRU, OBJECT should not reveal expired keys on replica (#8016)
The bug was introduced by #5021 which only attempted avoid EXIST on an
already expired key from returning 1 on a replica.

Before that commit, dbExists was used instead of
lookupKeyRead (which had an undesired effect to "touch" the LRU/LFU)

Other than that, this commit fixes OBJECT to also come empty handed on
expired keys in replica.

And DEBUG DIGEST-VALUE to behave like DEBUG OBJECT (get the data from
the key regardless of it's expired state)

(cherry picked from commit 168dcb549c3d5253fc69d6150ce98f8eb9ca0c99)
2021-01-12 16:25:37 +02:00
John Sully
64d24938b3 Merge branch 'repl_perf' into unstable
Former-commit-id: bc8cc1adb301d51e926f2552ce1eb28165ed569b
2020-12-24 02:22:57 +00:00
John Sully
6b6ae228e1 Merge branch 'repl_perf' into keydbpro
Former-commit-id: c4431a6be7a1ddc05abdd4510630fac2a2a6664e
2020-12-10 18:45:52 +00:00
John Sully
5c832c5ad0 Merge branch 'unstable' into keydbpro
Former-commit-id: b7a1e16c0f04e8aeb3764e3681fa14fc0f97f6a3
2020-12-10 02:37:28 +00:00
Kajaruban Surendran
188e7a5693 Configurable option for MOTD
Former-commit-id: 49a89d636ba698dbd0858d5059d3d6387c8c1fc7
2020-11-30 10:42:48 -05:00
John Sully
50c2a8524c Fix issue where active replication doesn't replicate RDB data
Former-commit-id: 527b7eb0742567302e0343e3acbed9814c0cbb95
2020-11-23 02:01:40 +00:00
John Sully
3e828a5988 Ensure multithreaded tests pass
Former-commit-id: 0bcce502859647529b8835a4a101b64ddf0d625c
2020-11-13 21:08:10 +00:00
John Sully
973b769b21 Improve replication performance in multithreaded scenarios
Former-commit-id: 96e0b2a2b19df220975e61131cbc535b0c34a828
2020-11-13 21:08:10 +00:00
John Sully
4f7ac9c11f Second implementation of nested hashes
Former-commit-id: ba950a3d1f5708ed986f9b348eafcace6a7c22b9
2020-11-06 19:24:48 +00:00
Yossi Gottlieb
ad1ed7dcd0 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 bf5beab64a196214c3c741d9ef67d0446c6480c3)
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
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
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
WuYunlong
4a3330c941 Make main thread killable so that it can be canceled at any time.
Refine comment of makeThreadKillable().

This commit can be backported to 5.0, only if we also backport cf8a6e3.

Co-authored-by: Oran Agra <oran@redislabs.com>
(cherry picked from commit d2291627305d606a5d3b1e3b3bfa17ab10a3ef32)
2020-10-27 09:12:01 +02:00
Oran Agra
f216bf312a RM_GetContextFlags provides indication that we're in a fork child (#7783)
(cherry picked from commit 0b476b591d8b92e88ec56675e747de23968eeae0)
2020-10-27 09:12:01 +02:00