Skip to content

Commit

Permalink
Merge pull request #849 from Aiven-Open/handle-not-leader-for-partiti…
Browse files Browse the repository at this point in the history
…on-error

Retry on temporary errors from schema reader
  • Loading branch information
aiven-anton authored Apr 10, 2024
2 parents 45ae8ce + 65f3d52 commit a1f10ea
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions karapace/schema_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
InvalidReplicationFactorError,
KafkaConfigurationError,
KafkaTimeoutError,
LeaderNotAvailableError,
NoBrokersAvailable,
NodeNotReadyError,
NotLeaderForPartitionError,
TopicAlreadyExistsError,
TopicAuthorizationFailedError,
UnknownTopicOrPartitionError,
Expand Down Expand Up @@ -246,6 +248,8 @@ def _get_beginning_offset(self) -> int:
LOG.warning("Reading begin offsets timed out.")
except UnknownTopicOrPartitionError:
LOG.warning("Topic does not yet exist.")
except (LeaderNotAvailableError, NotLeaderForPartitionError):
LOG.warning("Retrying to find leader for schema topic partition.")
except Exception as e: # pylint: disable=broad-except
self.stats.unexpected_exception(ex=e, where="_get_beginning_offset")
LOG.exception("Unexpected exception when reading begin offsets.")
Expand All @@ -265,6 +269,9 @@ def _is_ready(self) -> bool:
except UnknownTopicOrPartitionError:
LOG.warning("Topic does not yet exist.")
return False
except (LeaderNotAvailableError, NotLeaderForPartitionError):
LOG.warning("Retrying to find leader for schema topic partition.")
return False
except Exception as e: # pylint: disable=broad-except
self.stats.unexpected_exception(ex=e, where="_is_ready")
LOG.exception("Unexpected exception when reading end offsets.")
Expand Down

0 comments on commit a1f10ea

Please sign in to comment.