Skip to content

Commit

Permalink
c/topics: use topic table revision to detect changes in generator
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 14726e2)
  • Loading branch information
mmaslankaprv authored and vbotbuildovich committed Apr 22, 2024
1 parent d263cba commit 557c48b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/v/cluster/topic_table_partition_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ topic_table_partition_generator_exception::
topic_table_partition_generator::topic_table_partition_generator(
ss::sharded<topic_table>& 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();
Expand All @@ -32,8 +32,7 @@ topic_table_partition_generator::topic_table_partition_generator(

ss::future<std::optional<topic_table_partition_generator::generator_type_t>>
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 "
Expand Down

0 comments on commit 557c48b

Please sign in to comment.