Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message in case of a Kafka timeout #491

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

juha-aiven
Copy link
Contributor

In the case that can be seen in the stacktrace below, the customer gets 500 internal error.

Add handling of KafkaTimeoutException and return HTTP 504 in that case.

Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/karapace/rapu.py", line 323, in _handle_request
  data = await callback(**callback_kwargs)
   File "/usr/lib/python3.10/site-packages/karapace/schema_registry_apis.py", line 491, in config_set
     self.schema_registry.send_config_message(compatibility_level=compatibility_level, subject=None)
   File "/usr/lib/python3.10/site-packages/karapace/schema_registry.py", line 483, in send_config_message
     return self.send_kafka_message(key, value)
   File "/usr/lib/python3.10/site-packages/karapace/schema_registry.py", line 408, in send_kafka_message
     future = self.producer.send(
   File "/usr/lib/python3.10/site-packages/kafka/producer/kafka.py", line 581, in send
     self._wait_on_metadata(topic, self.config['max_block_ms'] / 1000.0)
   File "/usr/lib/python3.10/site-packages/kafka/producer/kafka.py", line 707, in _wait_on_metadata
     raise Errors.KafkaTimeoutError(
 kafka.errors.KafkaTimeoutError: KafkaTimeoutError: Failed to update metadata after 2.0 secs.

In the case that can be seen in the stacktrace below, the customer gets 500 internal error.

Add handling of KafkaTimeoutException and return HTTP 504 in that case.

Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/karapace/rapu.py", line 323, in _handle_request
  data = await callback(**callback_kwargs)
   File "/usr/lib/python3.10/site-packages/karapace/schema_registry_apis.py", line 491, in config_set
     self.schema_registry.send_config_message(compatibility_level=compatibility_level, subject=None)
   File "/usr/lib/python3.10/site-packages/karapace/schema_registry.py", line 483, in send_config_message
     return self.send_kafka_message(key, value)
   File "/usr/lib/python3.10/site-packages/karapace/schema_registry.py", line 408, in send_kafka_message
     future = self.producer.send(
   File "/usr/lib/python3.10/site-packages/kafka/producer/kafka.py", line 581, in send
     self._wait_on_metadata(topic, self.config['max_block_ms'] / 1000.0)
   File "/usr/lib/python3.10/site-packages/kafka/producer/kafka.py", line 707, in _wait_on_metadata
     raise Errors.KafkaTimeoutError(
 kafka.errors.KafkaTimeoutError: KafkaTimeoutError: Failed to update metadata after 2.0 secs.
@juha-aiven juha-aiven force-pushed the juham-improve-error-code-on-kafka-timeout branch from 8bc360e to 222b239 Compare November 15, 2022 10:59
@juha-aiven juha-aiven marked this pull request as ready for review November 15, 2022 11:27
@juha-aiven juha-aiven requested review from a team as code owners November 15, 2022 11:27
@@ -52,6 +53,7 @@ class SchemaErrorCodes(Enum):
INVALID_SUBJECT = 42208
SCHEMA_TOO_LARGE_ERROR_CODE = 42209
NO_MASTER_ERROR = 50003
KAFKA_TIMEOUT_ERROR_CODE = 50004
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better error code would be 50002 which is OPERATION_TIMEOUT_ERROR_CODE in CSR.
50004 is reserved for unknown leader error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants