Skip to content

Commit

Permalink
Retry on temporary errors from schema reader
Browse files Browse the repository at this point in the history
If leader for partition is not available, it is a temporary error that
is resolved after re-fetching metadata.  Log, but ignore those errors.
  • Loading branch information
tvainika committed Apr 10, 2024
1 parent 45ae8ce commit 65f3d52
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 65f3d52

Please sign in to comment.