From 557c48b9746888cb67614bc05d9f9f867828b0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ma=C5=9Blanka?= Date: Mon, 22 Apr 2024 11:54:15 +0000 Subject: [PATCH] c/topics: use topic table revision to detect changes in generator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Topic table partition generator is a simple helper to asynchronously iterate over a topic table which may have a lot of elements. The generator validates if `topic_table` changed while the loop yield for the other tasks. The check was incorrect as it was validating the topic table revision which is updated after the snapshot is applied. Fixed the issue by validating it `_topics_map_revision` changed during the scheduling point. Fixes: #core-internal/1259 Signed-off-by: Michał Maślanka (cherry picked from commit 14726e21fb9ce993518268fe7fb2abba289f47ad) --- src/v/cluster/topic_table_partition_generator.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/v/cluster/topic_table_partition_generator.cc b/src/v/cluster/topic_table_partition_generator.cc index 5e2f5095541d2..db9de13b22d48 100644 --- a/src/v/cluster/topic_table_partition_generator.cc +++ b/src/v/cluster/topic_table_partition_generator.cc @@ -19,7 +19,7 @@ topic_table_partition_generator_exception:: topic_table_partition_generator::topic_table_partition_generator( ss::sharded& topic_table, size_t batch_size) : _topic_table(topic_table) - , _stable_revision_id(_topic_table.local().last_applied_revision()) + , _stable_revision_id(_topic_table.local().topics_map_revision()) , _batch_size(batch_size) { if (_topic_table.local()._topics.empty()) { _topic_iterator = _topic_table.local()._topics.end(); @@ -32,8 +32,7 @@ topic_table_partition_generator::topic_table_partition_generator( ss::future> topic_table_partition_generator::next_batch() { - const auto current_revision_id - = _topic_table.local().last_applied_revision(); + const auto current_revision_id = _topic_table.local().topics_map_revision(); if (current_revision_id != _stable_revision_id) { throw topic_table_partition_generator_exception(fmt::format( "Last applied revision id moved from {} to {} whilst "