cf-natali commented on a change in pull request #355: Handle EBUSY when
destroying a cgroup.
URL: https://github.com/apache/mesos/pull/355#discussion_r405018860
##########
File path: src/linux/cgroups.cpp
##########
@@ -696,13 +696,24 @@ Try<Nothing> remove(const string& hierarchy, const
string& cgroup)
string path = path::join(hierarchy, cgroup);
// Do NOT recursively remove cgroups.
- Try<Nothing> rmdir = os::rmdir(path, false);
- if (rmdir.isError()) {
- return Error(
+ // TODO The retry was added as a fix for kernel bug
+ // https://lkml.org/lkml/2020/1/15/1349
+ // where calling rmdir on a seemingly empty cgroup can fail
+ // with EBUSY while some tasks are exiting.
+ auto delay = Milliseconds(1);
+ for (auto retry = 10; ;) {
+ Try<Nothing> rmdir = os::rmdir(path, false);
+ if (!rmdir.isError()) {
+ return rmdir;
+ } else if (retry > 0) {
+ os::sleep(delay);
Review comment:
Hm, I'm still confused: in your version, you capture `retry` and `delay` in
the lambdas by value, so their modifications are lost:
```
return loop(
// NOTE: copy `delay` by value in the first lambda function.
[=]() mutable {
auto timeout = process::after(delay);
delay *= 2;
return timeout;
},
// NOTE: copy `retry` by value in the second lambda function.
[=](const Nothing&) mutable -> Future<ControlFlow<Nothing>> {
[...]
} else if ((errno == EBUSY) && (retry > 0)) {
--retry;
return process::Continue();
```
I think that with this, `delay` and `retry` will *not* be updated from one
iteration to the next: so basically we will keep retrying the `rmdir` every 1ms
forever.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services