Repository: mesos Updated Branches: refs/heads/1.3.x ea246f505 -> 7f993379f
Fixed a crash when metrics race with quota removal. This patch addresses a race condition in which the removal of a role from the allocator's quota sorter races with execution of a callback tied to a `PullGauge`. The gauge's callback assumed that the role would be present in the sorter, but it's possible for the role to be removed before the callback is executed. Review: https://reviews.apache.org/r/67104/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e55e9445 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e55e9445 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e55e9445 Branch: refs/heads/1.3.x Commit: e55e944557cfd237b728771e6ae179266d8019ba Parents: ea246f5 Author: Greg Mann <[email protected]> Authored: Mon May 14 09:21:26 2018 -0700 Committer: Greg Mann <[email protected]> Committed: Tue May 15 14:51:53 2018 -0700 ---------------------------------------------------------------------- src/master/allocator/mesos/hierarchical.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/e55e9445/src/master/allocator/mesos/hierarchical.cpp ---------------------------------------------------------------------- diff --git a/src/master/allocator/mesos/hierarchical.cpp b/src/master/allocator/mesos/hierarchical.cpp index b75ed9a..21e1aef 100644 --- a/src/master/allocator/mesos/hierarchical.cpp +++ b/src/master/allocator/mesos/hierarchical.cpp @@ -2163,8 +2163,14 @@ double HierarchicalAllocatorProcess::_quota_allocated( const string& role, const string& resource) { + if (!roleSorter->contains(role)) { + // This can occur when execution of this callback races with removal of the + // metric for a role which does not have any associated frameworks. + return 0.; + } + Option<Value::Scalar> used = - quotaRoleSorter->allocationScalarQuantities(role) + roleSorter->allocationScalarQuantities(role) .get<Value::Scalar>(resource); return used.isSome() ? used->value() : 0;
