From cd00378720459d92394697e2cb8086f30c220312 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 3 Mar 2020 10:09:06 -0600 Subject: [PATCH] common/ceph_time: tolerate mono time going backwards Some kernels (and possibly some hardware?) can trigger a monotonic clock that goes back in time. That, in turn, can lead to a negative monotonic time span. This would trigger an assert. This this problem seems to be widespread, tolerate the case and interpret it as a 0-length interval (vs something negative). Fixes: https://tracker.ceph.com/issues/44078 Fixes: https://tracker.ceph.com/issues/43365 Signed-off-by: Sage Weil --- src/common/ceph_time.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/ceph_time.h b/src/common/ceph_time.h index ae4a17c7812..f6185c88200 100644 --- a/src/common/ceph_time.h +++ b/src/common/ceph_time.h @@ -482,7 +482,19 @@ inline timespan abs(signedspan z) { timespan(-z.count()); } inline timespan to_timespan(signedspan z) { - ceph_assert(z >= signedspan::zero()); + if (z < signedspan::zero()) { + //ceph_assert(z >= signedspan::zero()); + // There is a kernel bug that seems to be triggering this assert. We've + // seen it in: + // centos 8.1: 4.18.0-147.el8.x86_64 + // debian 10.3: 4.19.0-8-amd64 + // debian 10.1: 4.19.67-2+deb10u1 + // ubuntu 18.04 + // see bugs: + // https://tracker.ceph.com/issues/43365 + // https://tracker.ceph.com/issues/44078 + z = signedspan::zero(); + } return std::chrono::duration_cast(z); } -- 2.39.5