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

schema-reader: Log the erroring kafka message key #963

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

nosahama
Copy link
Contributor

About this change - What it does

  • we add the kafka message key to the log in the case of an error, this makes it easier to debug issues
  • we also add a check for kafka messages without a key

@nosahama nosahama requested review from a team as code owners September 25, 2024 13:53
@nosahama nosahama force-pushed the nosahama/log-msg-key-on-schema-reader-error branch from 515f785 to a43b230 Compare September 25, 2024 14:05
Copy link

github-actions bot commented Sep 25, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  karapace
  schema_reader.py
Project Total  

This report was generated by python-coverage-comment-action

@davide-armand
Copy link
Contributor

Left a comment but LGTM

- we add the kafka message key to the log in the case of an error,
this makes it easier to debug issues
- we also add a check for kafka messages without a key
@nosahama nosahama force-pushed the nosahama/log-msg-key-on-schema-reader-error branch from a43b230 to 25889f0 Compare September 25, 2024 14:57
Copy link
Contributor

@eliax1996 eliax1996 left a comment

Choose a reason for hiding this comment

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

LGTM

@eliax1996 eliax1996 enabled auto-merge September 25, 2024 15:12
@eliax1996 eliax1996 merged commit 349ae92 into main Sep 25, 2024
9 checks passed
@eliax1996 eliax1996 deleted the nosahama/log-msg-key-on-schema-reader-error branch September 25, 2024 15:22
Comment on lines +366 to +370
except AssertionError as exc:
LOG.warning("Empty msg.key() at offset %s", msg.offset())
self.offset = msg.offset() # Invalid entry shall also move the offset so Karapace makes progress.
self.kafka_error_handler.handle_error(location=KafkaErrorLocation.SCHEMA_READER, error=exc)
continue # [non-strict mode]
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this looks like a bit of a sketchy idea, an AssertionError could come from deeper in the code, and this essentially abuses the assert to function as a goto. AssertionError should really never be caught, bar some special cases in test harnessing code.

Copy link
Contributor

Choose a reason for hiding this comment

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

If an AssertionError is raised from msg.key() or msg.error(), the correct behavior is for the code to fall over, and be restarted by the scheduler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this had existed prior to this change, we can take a look later.

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.

4 participants