From 2252c1c3be1413912391d8b7695b061c792be51d 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 54cb5529d5353..4c0ce1d44ceb9 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[offset_key] = std::move(tmp); return res; }, [offsets](materialized_segment_ptr& m_state) {