-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Introduce memory management on cluster link buffers #9774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce memory management on cluster link buffers #9774
Conversation
|
This is a new PR that replaces old PR: ny0312#1 There were some comments left on the old PR that are now addressed in this new PR. |
madolson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some thoughts on the other PR, but this one seems OK to me. We also need a change in redis.conf to describe the parameter.
madolson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise.
|
@redis/core-team Please review, there are two core team decisions. The first is the config to limit maximum amount of outbound data, the second is the command to describe the information for the cluster links. |
oranagra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i didn't review the majority of the code. just the parts related to the new interfaces.
i suppose the feature is valid, but i'd like to argue about the default value for the config.
|
@ny0312 The decision was that we will set the default to 0, implying infinite today, and we'll evaluate how it works. We'll document that you can do something about it. |
|
谢谢
|
6206889 to
58beb95
Compare
|
Accompanying doc PR: redis/redis-doc#1710 Thanks. |
madolson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @redis/core-team back to ya'll for approval.
oranagra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one comment. otherwise LTTM.
|
The top comment of the PR is outdated too. |
oranagra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
@ny0312 Sorry to ask more from you, but we moved to a new command definition system: You can transfer the contents of the doc PR over to this CR now. @yossigo Can you approve the major changes if you have time, so we can get this merged? |
|
@oranagra Can you verify that commands.c and the json file were implemented correctly? They look right to me but I haven't looked that much. Besides that I think this is ready to merge along with the doc PR. |
oranagra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
|
Introduce memory management on cluster link buffers: * Introduce a new `cluster-link-sendbuf-limit` config that caps memory usage of cluster bus link send buffers. * Introduce a new `CLUSTER LINKS` command that displays current TCP links to/from peers. * Introduce a new `mem_cluster_links` field under `INFO` command output, which displays the overall memory usage by all current cluster links. * Introduce a new `total_cluster_links_buffer_limit_exceeded` field under `CLUSTER INFO` command output, which displays the accumulated count of cluster links freed due to `cluster-link-sendbuf-limit`.
|
@ny0312 can you please look into these failures. |
|
@oranagra @ny0312 that issue specifically is caused because the cluster tests do hard resets in between tests, and the nodes may not have re-established all links, especially for slower tests. I was looking into the other failures a bit last night, and don't have any other suggested fixes at the moment. |
|
some failure in the FreeBSD CI in |
|
I'll ping @ny0312 on our AWS slack, I'm not sure he's noticed this. |
|
@madolson a few days ago he told me he's on vacation 8-) |
|
I probably should have known that :D. I was able to slowly validate it was this commit that is causing both the crashes on sanitizer and the buffer disconnect issues. I have no idea why though, it might just be we're dumping a bunch of memory into the test which doesn't seem to be done elsewhere in the cluster test. |
|
I'm back. I will sync up with Maddy and investigate and fix what is going on. Sorry and thanks. |
|
any news? it could be just a random failure of the slow freebsd CI (we see broken pipes in random places). as well as other types of errors, on non-freebsd CI.
|
|
Hey sorry for the late response. But I have been trying to reproduce this test failure, but couldn't. This is the command I run (I copied it from https://github.com/redis/redis/runs/4654435988?check_suite_focus=true): I've run it numerous times locally. I've run it numerous times on a FreeBSD 64 bit EC2. All with the latest From the error message, it looks like Redis crashed during my test. The crash must be flaky and non-deterministic. Any ideas that could help reproduce it? Another question - how do I preserve redis logs from these test runs? |
|
@ny0312 It's bound to happen every time on my local freebsd vm, I've only allocated 1 core and 256M RAM to it, and since I don't know about clusters, there's no way to solve this problem directly, maybe I can package the logs and send them to you. I use the following to reproduce. |
|
When memory is exhausted, this test is bound to fail, and here are some logs after enabling |
|
Huh, looks like file descriptors are exhausted? @sundb , You mentioned you reproduced this on a FreeBSD vm. Could you please share what exactly is your setup? Which VirtualMachine? In the meanwhile, I will try to simulate your setup with a EC2 to reproduce. i.e. I will provision a EC2 with FreeBSD, 1 core and 256MB memory. Also, if you could share the full Redis logs for the failed test, that'd be great. (For example you could attach a file here, or use something like https://justpaste.it/) Thanks a lot! |
|
@ny0312 justpaste.it can't upload files, so I created a repository to hold the logs(https://github.com/sundb/log).
diff --git a/tests/cluster/run.tcl b/tests/cluster/run.tcl
index c81d8f39d..ddf9986aa 100644
--- a/tests/cluster/run.tcl
+++ b/tests/cluster/run.tcl
@@ -17,6 +17,7 @@ proc main {} {
"appendonly yes"
"enable-protected-configs yes"
"enable-debug-command yes"
+ "loglevel debug"
}
run_tests
cleanup |
|
OK. I am able to reproduce the test failure with 1 core, 512MB RAM 64bit FreeBSD. The failure is Redis getting OOM killed by kernel due to out of swap. In the test, I'm allowing cluster link buffers to grow up to 32MB. That proved to be too much for the FreeBSD test environment used by the daily runs. I'm currently experimenting with a new cluster link buffer limit in my test. The challenge is that in order to trigger the condition under test, which is a cluster bus link being freed once over the limit, I need to fill up the cluster link buffer. But to fill up the link buffer, I need to first fill up the TCP write buffer in the kernel level, which varies from OS to OS. I will post a fix PR as soon as I can get a good stable buffer limit. |
|
note that in the "other" test suite, we have the also, what about the test failures in the sanitizer runs, like this one: not sure if this one is related: |
This has a different root cause. In the test, I'm assuming as soon as I send a large PUBLISH command to fill up a cluster link, the link will be freed. But in reality the link will only get freed in the next
This link has two failures.
|
|
i didn't look at the test, but i wanna mention that there are other tests in which we struggled to fill output buffers and had to deal with the OS socket buffers swallowing our bytes. i think these are in: IIRC the best approach we had was to pause the destination process, and then gradually fill more and more data until we see it starts piling up, then stop. |
|
@ny0312 Don't know about this test but might be related with timing. I increase "cluster-node-timeout" for something else on my branch, I see this test fails here. Just fyi. |
This PR introduced memory management on cluster bus link send buffers, to address issues raised in #9688.
The interface changes are (need core-team consensus):
cluster-link-sendbuf-limitconfig that caps memory usage of cluster bus link send buffers.CLUSTER LINKScommand that displays current TCP links to/from peers as a RESP3 map.mem_cluster_linksfield under theMemorysection ofINFOcommand output, which displays the overall memory usage by all current cluster links.mem_cluster_linksis also deducted fromused_memory_datasetto better isolate the memory usage of real key values.maxmemorylimit, so over consumption by cluster links can still cause evictions orOOMerrors (no behavior change).total_cluster_links_buffer_limit_exceededfield under theCLUSTER INFOcommand output, which displays the accumulated count of cluster links freed due tocluster-link-sendbuf-limit.On an implementation level:
clusterNodestruct, added aninbound_linkfield pointing to the inbound link accepted from thisnode. Before this change, inbound links are not associated with the correspondingclusterNodeand are loosely managed.