diff --git a/service/storage_proxy.cc b/service/storage_proxy.cc index 72f97f8426..aafe2b3be8 100644 --- a/service/storage_proxy.cc +++ b/service/storage_proxy.cc @@ -685,13 +685,17 @@ public: } }; -static future> sleep_and_restart() { +static future<> sleep_approx_50ms() { static thread_local std::default_random_engine re{std::random_device{}()}; - std::uniform_int_distribution<> dist(0, 100); - return sleep(std::chrono::milliseconds(dist(re))).then([] { + static thread_local std::uniform_int_distribution<> dist(0, 100); + return seastar::sleep(std::chrono::milliseconds(dist(re))); +} + +static future> sleep_and_restart() { + return sleep_approx_50ms().then([] { return std::optional(); // continue }); -}; +} /** * Begin a Paxos session by sending a prepare request and completing any in-progress requests seen in the replies. @@ -3970,9 +3974,7 @@ future storage_proxy::cas(schema_ptr schema, shared_ptr reque handler->id()); tracing::trace(handler->tr_state, "PAXOS proposal not accepted (pre-empted by a higher ballot)"); ++contentions; - return seastar::sleep(100ms).then([] { - return std::optional(); - }); + return sleep_approx_50ms().then([] { return std::optional(); }); }); }); });