diff --git a/service/storage_proxy.cc b/service/storage_proxy.cc index 4e9f09462d..4eaa7bbcbb 100644 --- a/service/storage_proxy.cc +++ b/service/storage_proxy.cc @@ -3323,7 +3323,10 @@ public: } exec->on_read_resolved(); } else { // digest mismatch - if (is_datacenter_local(exec->_cl)) { + // Do not optimize cross-dc repair if read_timestamp is missing (or just negative) + // We're interested in reads that happen within write_timeout of a write, + // and comparing a timestamp that is too far causes int overflow (#5556) + if (is_datacenter_local(exec->_cl) && exec->_cmd->read_timestamp >= api::timestamp_type(0)) { auto write_timeout = exec->_proxy->_db.local().get_config().write_request_timeout_in_ms() * 1000; auto delta = int64_t(digest_resolver->last_modified()) - int64_t(exec->_cmd->read_timestamp); if (std::abs(delta) <= write_timeout) {