@@ -40,8 +40,17 @@ class replicated_metadata_persistence : public lsm::io::metadata_persistence {
4040 auto _ = _gate.hold ();
4141 auto term_result = co_await _stm->sync (std::chrono::seconds (30 ), _as);
4242 if (!term_result.has_value ()) {
43- throw lsm::io_error_exception (
44- " Failed to sync when loading manifest" );
43+ using enum stm::errc;
44+ switch (term_result.error ()) {
45+ case shutting_down:
46+ throw lsm::abort_requested_exception (
47+ " shutting down while syncing STM when loading manifest" );
48+ case not_leader:
49+ case raft_error:
50+ throw lsm::io_error_exception (
51+ " failed to sync STM when loading manifest: {}" ,
52+ term_result.error ());
53+ }
4554 }
4655 if (_stm->state ().domain_uuid != _expected_domain_uuid) {
4756 // Caller needs to rebuild the metadata persistence with the
@@ -71,6 +80,7 @@ class replicated_metadata_persistence : public lsm::io::metadata_persistence {
7180
7281 ss::future<>
7382 write_manifest (lsm::internal::database_epoch epoch, iobuf b) override {
83+ _as.check ();
7484 auto h = _gate.hold ();
7585 co_await _cloud_persistence->write_manifest (epoch, b.share ());
7686
@@ -98,16 +108,25 @@ class replicated_metadata_persistence : public lsm::io::metadata_persistence {
98108
99109 auto replicate_result = co_await _stm->replicate_and_wait (
100110 _stm->state ().to_term (epoch), std::move (batch), _as);
101-
102111 if (!replicate_result.has_value ()) {
103- throw lsm::io_error_exception (
104- " Replication error after persisting manifest: {}" ,
105- int (replicate_result.error ()));
112+ using enum stm::errc;
113+ switch (replicate_result.error ()) {
114+ case shutting_down:
115+ throw lsm::abort_requested_exception (
116+ " shutting down while replicating manifest after persisting" );
117+ case not_leader:
118+ case raft_error:
119+ throw lsm::io_error_exception (
120+ " replication error after persisting manifest: {}" ,
121+ replicate_result.error ());
122+ }
106123 }
107124 }
108125
109126 ss::future<> close () override {
110- _as.request_abort ();
127+ _as.request_abort_ex (
128+ lsm::abort_requested_exception (
129+ " replicated_persistence shutting down" ));
111130 auto fut = _gate.close ();
112131 auto persistence_fut = _cloud_persistence->close ();
113132 co_await std::move (persistence_fut);
0 commit comments