You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iggy.apache.org by pi...@apache.org on 2025/07/21 13:05:43 UTC

(iggy) 01/01: fix(server): improve updating topic for named ID

This is an automated email from the ASF dual-hosted git repository.

piotr pushed a commit to branch fix_update_topic
in repository https://gitbox.apache.org/repos/asf/iggy.git

commit 1667971c264d7f758a05527ee766cb063cf6c6f7
Author: spetz <pi...@gmail.com>
AuthorDate: Mon Jul 21 15:05:34 2025 +0200

    fix(server): improve updating topic for named ID
---
 core/server/src/streaming/streams/topics.rs | 7 +++++--
 core/server/src/streaming/systems/topics.rs | 4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/core/server/src/streaming/streams/topics.rs b/core/server/src/streaming/streams/topics.rs
index f8c742be..dbc5b1e6 100644
--- a/core/server/src/streaming/streams/topics.rs
+++ b/core/server/src/streaming/streams/topics.rs
@@ -137,8 +137,6 @@ impl Stream {
         };
 
         {
-            self.topics_ids.remove(&old_topic_name.clone());
-            self.topics_ids.insert(name.to_owned(), topic_id);
             let topic = self.get_topic_mut(id).with_error_context(|error| {
                 format!("{COMPONENT} (error: {error}) - failed to get mutable reference to topic with id {id}")
             })?;
@@ -161,6 +159,11 @@ impl Stream {
             info!("Updated topic: {topic}");
         }
 
+        {
+            self.topics_ids.remove(&old_topic_name.clone());
+            self.topics_ids.insert(name.to_owned(), topic_id);
+        }
+
         Ok(())
     }
 
diff --git a/core/server/src/streaming/systems/topics.rs b/core/server/src/streaming/systems/topics.rs
index a61f5464..a384cb43 100644
--- a/core/server/src/streaming/systems/topics.rs
+++ b/core/server/src/streaming/systems/topics.rs
@@ -177,6 +177,7 @@ impl System {
         replication_factor: Option<u8>,
     ) -> Result<&Topic, IggyError> {
         self.ensure_authenticated(session)?;
+        let topic_numeric_id;
         {
             let topic = self
                 .find_topic(session, stream_id, topic_id)
@@ -185,6 +186,7 @@ impl System {
                         "{COMPONENT} (error: {error}) - failed to find topic with ID: {topic_id}"
                     )
                 })?;
+            topic_numeric_id = topic.topic_id;
             self.permissioner.update_topic(
                 session.get_user_id(),
                 topic.stream_id,
@@ -222,7 +224,7 @@ impl System {
             .with_error_context(|error| {
                 format!("{COMPONENT} (error: {error}) - failed to get stream with ID: {stream_id}")
             })?
-            .get_topic(topic_id)
+            .get_topic(&Identifier::numeric(topic_numeric_id)?)
             .with_error_context(|error| {
                 format!("{COMPONENT} (error: {error}) - failed to get topic with ID: {topic_id} in stream with ID: {stream_id}")
             })