|
16 | 16 | #include "cloud_topics/level_one/compaction/worker.h" |
17 | 17 | #include "cloud_topics/level_one/metastore/replicated_metastore.h" |
18 | 18 | #include "model/fundamental.h" |
| 19 | +#include "ssx/future-util.h" |
19 | 20 |
|
20 | 21 | namespace cloud_topics::l1 { |
21 | 22 |
|
@@ -43,7 +44,10 @@ ss::future<> worker_manager::start() { |
43 | 44 | co_await _workers.invoke_on_all(&compaction_worker::start); |
44 | 45 | } |
45 | 46 |
|
46 | | -ss::future<> worker_manager::stop() { co_await _workers.stop(); } |
| 47 | +ss::future<> worker_manager::stop() { |
| 48 | + co_await _gate.close(); |
| 49 | + co_await _workers.stop(); |
| 50 | +} |
47 | 51 |
|
48 | 52 | std::optional<foreign_log_compaction_meta_ptr> |
49 | 53 | worker_manager::try_acquire_work(ss::shard_id shard) { |
@@ -93,35 +97,39 @@ void worker_manager::complete_work(log_compaction_meta* log) { |
93 | 97 | _probe.log_compacted(); |
94 | 98 | } |
95 | 99 |
|
96 | | -ss::future<> |
97 | | -worker_manager::request_stop_compaction(log_compaction_meta_ptr log) { |
| 100 | +void worker_manager::request_stop_compaction(log_compaction_meta_ptr log) { |
98 | 101 | if (!log) { |
99 | | - co_return; |
| 102 | + return; |
100 | 103 | } |
101 | 104 |
|
102 | 105 | auto shard_opt = log->inflight_shard; |
103 | 106 | if (!shard_opt.has_value()) { |
104 | | - co_return; |
| 107 | + return; |
105 | 108 | } |
106 | 109 |
|
107 | 110 | auto shard = shard_opt.value(); |
108 | 111 |
|
109 | | - co_await _workers.invoke_on(shard, [](compaction_worker& worker) { |
110 | | - return worker.terminate_current_job(); |
| 112 | + ssx::spawn_with_gate(_gate, [this, shard]() { |
| 113 | + return _workers.invoke_on(shard, [](compaction_worker& worker) { |
| 114 | + return worker.terminate_current_job(); |
| 115 | + }); |
111 | 116 | }); |
112 | 117 | } |
113 | 118 |
|
114 | 119 | ss::future<> worker_manager::alert_workers() { |
| 120 | + auto guard = _gate.hold(); |
115 | 121 | co_await _workers.invoke_on_all( |
116 | 122 | [](compaction_worker& worker) { worker.alert_worker(); }); |
117 | 123 | } |
118 | 124 |
|
119 | 125 | ss::future<> worker_manager::pause_worker(ss::shard_id worker) { |
| 126 | + auto guard = _gate.hold(); |
120 | 127 | co_await _workers.invoke_on( |
121 | 128 | worker, [](compaction_worker& worker) { return worker.pause_worker(); }); |
122 | 129 | } |
123 | 130 |
|
124 | 131 | ss::future<> worker_manager::resume_worker(ss::shard_id worker) { |
| 132 | + auto guard = _gate.hold(); |
125 | 133 | co_await _workers.invoke_on( |
126 | 134 | worker, [](compaction_worker& worker) { return worker.resume_worker(); }); |
127 | 135 | } |
|
0 commit comments