From 28aab3f35c40c9a5e36b847bc8fdc0e8efe1fe18 Mon Sep 17 00:00:00 2001 From: Elena Anyusheva Date: Mon, 1 Aug 2022 13:25:30 +0200 Subject: [PATCH] cloud_storage: don't capture reference to btree element Reference to the absl::btree_map is not stable, so don't use a reference that was captured before the scheduling point. --- src/v/cloud_storage/remote_partition.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/v/cloud_storage/remote_partition.cc b/src/v/cloud_storage/remote_partition.cc index 54cb5529d535..75bd9bbbae4a 100644 --- a/src/v/cloud_storage/remote_partition.cc +++ b/src/v/cloud_storage/remote_partition.cc @@ -517,15 +517,14 @@ remote_partition::aborted_transactions(offset_range offsets) { if (it->first > offsets.end) { break; } - auto& st = it->second; auto tx = co_await ss::visit( - st, - [this, &st, offsets, offset_key = it->first]( + it->second, + [this, offsets, offset_key = it->first]( offloaded_segment_state& off_state) { auto tmp = off_state->materialize(*this, offset_key); auto res = tmp->segment->aborted_transactions( offsets.begin_rp, offsets.end_rp); - st = std::move(tmp); + _segments.insert_or_assign(offset_key, std::move(tmp)); return res; }, [offsets](materialized_segment_ptr& m_state) {