[
https://issues.apache.org/jira/browse/MESOS-3552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14937026#comment-14937026
]
Mandeep Chadha commented on MESOS-3552:
---------------------------------------
One more example of ( double == double) check - though doesn't result in crash
:)
Util function will be useful but still have to be enforced. Maybe it is time to
wrap double primitive into Double ( primitive wrapper class) ? That way we
don't have to chase down every (double == double) check.
https://github.com/apache/mesos/blob/master/src/master/allocator/sorter/drf/sorter.cpp#L34
bool DRFComparator::operator()(const Client& client1, const Client& client2)
{
if (client1.share == client2.share) {
if (client1.allocations == client2.allocations) {
return client1.name < client2.name;
}
return client1.allocations < client2.allocations;
}
return client1.share < client2.share;
}
Where share is double :
https://github.com/apache/mesos/blob/master/src/master/allocator/sorter/drf/sorter.hpp#L43
struct Client
{
Client(const std::string& _name, double _share, uint64_t _allocations)
: name(_name), share(_share), allocations(_allocations) {}
std::string name;
double share;
-------
As far as this bug, we can use :
"
The CHECK_DOUBLE_EQ macro checks the equality of two floating point values,
accepting a small error margin. CHECK_NEAR accepts a third floating point
argument, which specifies the acceptable error margin.
"
> Check failed: result.cpus() == cpus() && result.mem() == mem() &&
> result.disk() == disk() && result.ports() == ports()
> -----------------------------------------------------------------------------------------------------------------------
>
> Key: MESOS-3552
> URL: https://issues.apache.org/jira/browse/MESOS-3552
> Project: Mesos
> Issue Type: Bug
> Components: master
> Affects Versions: 0.24.1
> Reporter: Mandeep Chadha
> Assignee: Mandeep Chadha
>
> result.cpus() == cpus() check is failing due to ( double == double )
> comparison problem.
> Root Cause :
> Framework requested 0.1 cpu reservation for the first task. So far so good.
> Next Reserve operation — lead to double operations resulting in following
> double values :
> results.cpus() : 23.9999999999999964472863211995 cpus() : 24
> And the check ( result.cpus() == cpus() ) failed.
> The double arithmetic operations caused results.cpus() value to be :
> 23.9999999999999964472863211995 and hence ( 23.9999999999999964472863211995
> == 24 ) failed.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)