Skip to content

Commit

Permalink
fix: pg metadata on a missing topic would cause a sql fault
Browse files Browse the repository at this point in the history
  • Loading branch information
shortishly committed Sep 24, 2024
1 parent 3029a1b commit ca3b3df
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tansu-storage/src/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,11 +1000,11 @@ impl Storage for Postgres {
.inspect_err(|err|{let cluster = self.cluster.as_str();error!(?err, ?cluster, ?name);})?;

match c
.query_one(&prepared, &[&self.cluster, &name.as_str()])
.query_opt(&prepared, &[&self.cluster, &name.as_str()])
.await
.inspect_err(|err|error!(?err))
{
Ok(row) => {
Ok(Some(row)) => {
let error_code = ErrorCode::None.into();
let topic_id = row
.try_get::<_, Uuid>(0)
Expand Down Expand Up @@ -1050,6 +1050,18 @@ impl Storage for Postgres {
topic_authorized_operations: Some(-2147483648),
}
}

Ok(None) => {
MetadataResponseTopic {
error_code: ErrorCode::UnknownTopicOrPartition.into(),
name: Some(name.into()),
topic_id: Some(NULL_TOPIC_ID),
is_internal: Some(false),
partitions: Some([].into()),
topic_authorized_operations: Some(-2147483648),
}
}

Err(reason) => {
debug!(?reason);
MetadataResponseTopic {
Expand Down

0 comments on commit ca3b3df

Please sign in to comment.