Skip to content

Commit 25ff18b

Browse files
committed
crimson/client_request: support inject delay request
Signed-off-by: junxiang Mu <[email protected]>
1 parent 34f209f commit 25ff18b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/crimson/osd/osd_operations/client_request.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,9 @@ ClientRequest::do_process(
462462
co_return;
463463
}
464464
}
465+
466+
co_await maybe_inject_delay();
467+
465468
if (m->get_oid().name.size()
466469
> crimson::common::local_conf()->osd_max_object_name_len) {
467470
co_await reply_op_error(pg, -ENAMETOOLONG);

src/crimson/osd/osd_operations/client_request.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include <seastar/core/future.hh>
7+
#include <seastar/core/sleep.hh>
78

89
#include <boost/intrusive/list.hpp>
910
#include <boost/intrusive_ptr.hpp>
@@ -321,6 +322,18 @@ class ClientRequest final : public PhasedOperationT<ClientRequest>,
321322
};
322323

323324
void put_historic() const;
325+
static interruptible_future<> maybe_inject_delay() {
326+
if (common::local_conf()->osd_debug_inject_dispatch_delay_probability > 0) {
327+
if (rand() % 10000 <
328+
common::local_conf()->osd_debug_inject_dispatch_delay_probability * 10000) {
329+
auto delay_duration = std::chrono::duration<double>(
330+
common::local_conf()->osd_debug_inject_dispatch_delay_duration);
331+
auto a_while = std::chrono::duration_cast<std::chrono::seconds>(delay_duration);
332+
return seastar::sleep(a_while);
333+
}
334+
}
335+
return seastar::now();
336+
}
324337
};
325338

326339
}

0 commit comments

Comments
 (0)