30#include <seastar/util/noncopyable_function.hh>
31#include <seastar/util/critical_alloc_section.hh>
32#include <seastar/util/modules.hh>
55 uint64_t _alloc_count = 0;
56 uint64_t _fail_at = std::numeric_limits<uint64_t>::max();
64 if (is_critical_alloc_section()) {
67 if (_alloc_count >= _fail_at) {
80 _fail_at = _alloc_count + count;
86 _fail_at = std::numeric_limits<uint64_t>::max();
106 return the_alloc_failure_injector;
109#ifdef SEASTAR_ENABLE_ALLOC_FAILURE_INJECTION
111#ifdef SEASTAR_DEFAULT_ALLOCATOR
112#error SEASTAR_ENABLE_ALLOC_FAILURE_INJECTION is not supported when using SEASTAR_DEFAULT_ALLOCATOR
126#ifdef SEASTAR_ENABLE_ALLOC_FAILURE_INJECTION
Definition: alloc_failure_injector.hh:54
void fail_after(uint64_t count)
Will cause count-th allocation point from now to fail, counting from 0.
Definition: alloc_failure_injector.hh:79
bool failed() const
Returns true iff allocation was failed since last fail_after().
Definition: alloc_failure_injector.hh:90
void on_alloc_point()
Marks a point in code which should be considered for failure injection.
Definition: alloc_failure_injector.hh:63
void cancel()
Cancels the failure scheduled by fail_after().
Definition: alloc_failure_injector.hh:85
uint64_t alloc_count() const
Counts encountered allocation points which didn't fail and didn't have failure suppressed.
Definition: alloc_failure_injector.hh:74
void run_with_callback(noncopyable_function< void()> callback, noncopyable_function< void()> to_run)
Runs given function with a custom failure action instead of the default std::bad_alloc throw.
void with_allocation_failures(noncopyable_function< void()> func)
void on_alloc_point()
Marks a point in code which should be considered for failure injection.
Definition: alloc_failure_injector.hh:125
alloc_failure_injector & local_failure_injector()
Return the shard-local alloc_failure_injector instance.
Definition: alloc_failure_injector.hh:105
Definition: alloc_failure_injector.hh:118
Definition: critical_alloc_section.hh:80
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Definition: noncopyable_function.hh:37