Repository: mesos
Updated Branches:
  refs/heads/1.6.x 9a30d4ebf -> 22571c72f


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/567c6500
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/567c6500
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/567c6500

Branch: refs/heads/1.6.x
Commit: 567c6500ddb5fdff111ceef78d382066825fc4c8
Parents: 9a30d4e
Author: Greg Mann <[email protected]>
Authored: Mon May 14 09:21:26 2018 -0700
Committer: Greg Mann <[email protected]>
Committed: Mon May 14 10:09:15 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/567c6500/src/master/allocator/mesos/hierarchical.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/mesos/hierarchical.cpp 
b/src/master/allocator/mesos/hierarchical.cpp
index 1000968..c221999 100644
--- a/src/master/allocator/mesos/hierarchical.cpp
+++ b/src/master/allocator/mesos/hierarchical.cpp
@@ -2512,8 +2512,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;

Reply via email to