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

offline_log_viewer: allow reading newer versions of envelopes #23803

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

Conversation

nvartolomei
Copy link
Contributor

Before this commit offline log viewer would refuse reading envelopes if their version was higher than max_version. That is an overly restrictive constraint. Our envelopes are designed to be forward and backwards compatible so in most of the cases an older implementation of the log viewer should be able to read newer versions of the envelopes just fine.

This commit implements that. Instead of putting a constraint on version we constrain only compat_version like regular redpanda deserialization would do.

Additional changes include issuing a warning if offline log viewer compat version is lower than envelope version. This means that offline log viewer will be able to decode only a subset of the envelope.

And obviously added code to skip over data that can't be read by the offline log viewer.

Breaking changes in the envelopes are introduced by bumping compat version. In that case offline log viewer will refuse the decoding as expected.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v24.2.x
  • v24.1.x
  • v23.3.x

Release Notes

  • none

@nvartolomei nvartolomei force-pushed the nv/offline-log-viewer-forward-compatibility branch from f4cd3ec to 612e962 Compare October 16, 2024 13:47
@nvartolomei
Copy link
Contributor Author

/dt

@vbotbuildovich
Copy link
Collaborator

Retry command for Build#56669

please wait until all jobs are finished before running the slash command

/ci-repeat 1
tests/rptest/transactions/transactions_test.py::TxUpgradeRevertTest.test_snapshot_compatibility

@nvartolomei
Copy link
Contributor Author

Only one known failure test_snapshot_compatibility. Good to review and merge. 🙇‍♂️

rdr.read_envelope(read_topic_properties_serde, max_version=10),
rdr.read_envelope(read_topic_properties_serde, max_compat_version=10),
Copy link
Member

Choose a reason for hiding this comment

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

first contact w/ this code, so sorry if these are obvious. few q's out of curiosity:

  1. the max_version/max_compat_version here is expected to always be in sync w/ T::redpanda_serde_version right? along w/ the corresponding type_read thing?
    a. thought: couldn't we keep the max version & field reader info together? or is that not general enough?
  2. All this is updated manually, ideally in lockstep with changes to relevant envelopes?
  3. Assuming (2), have we ever talked about auto-generating a table or something? Thinking about it for 2s it sounds really complicated, but idk.
    a. 😈 idea: Python bindings for v::serde

Comment on lines 153 to 165
if envelope.compat_version <= max_compat_version:
v = type_read(self, envelope.version)

# Skip the rest of the envelope.
bytes_left_in_envelope -= self.stream.tell(
) - envelope_start_pos
self.stream.read(bytes_left_in_envelope)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to cover this case:

if (unlikely(version < Type::redpanda_serde_compat_version)) {

Like if the type_read implies a compat version that exceeds the encoded version of the binary blob we're reading, should we reject that as well?

@nvartolomei nvartolomei force-pushed the nv/offline-log-viewer-forward-compatibility branch from 612e962 to 2e45890 Compare October 18, 2024 14:40
Before this commit offline log viewer would refuse reading envelopes if
their version was higher than max_version. That is an overly restrictive
constraint. Our envelopes are designed to be forward and backwards
compatible so in most of the cases an older implementation of the log
viewer should be able to read newer versions of the envelopes just fine.

This commit implements that. Instead of putting a constraint on
version we constrain only compat_version like regular redpanda
deserialization would do.

Additional changes include issuing a warning if offline log viewer
compat version is lower than envelope version. This means that offline
log viewer will be able to decode only a subset of the envelope.

And obviously added code to skip over data that can't be read by the
offline log viewer.

Breaking changes in the envelopes are introduced by bumping compat
version. In that case offline log viewer will refuse the decoding as
expected.
@nvartolomei
Copy link
Contributor Author

@oleiman great feedback. I forgot to consider when serde structs bump compat_version. Force-pushed some changes, the meat of the change is the highlighted lines

https://github.com/redpanda-data/redpanda/compare/612e962455700d71e7f176e27f3f162e18b60b9e..2e45890e0d80aa5f2268740d29c632e84ca29fab#diff-1f2ab7da52d09fc230c1df835b829e2bd02e68e94046245c952fe5c347d82e64R146-R158

What do you think about merging this and working on compat_version thing later? I did spot check and couldn't find any structs relevant for offline log viewer that have compat_version > 0.

My thinking is that offline log viewer should be allowed to evolve separately from the rest of the codebase and a newer log viewer should always be able to read older data. This is what this commit achieves.

The only exception at this moment is when compat_version is bumped. To support reading older logs after that point we will need to provide multiple read_type implementations somehow. One for each compat_version.

Copy link
Member

@oleiman oleiman left a comment

Choose a reason for hiding this comment

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

What do you think about merging this and working on compat_version thing later? I did spot check and couldn't find any structs relevant for offline log viewer that have compat_version > 0.

sgtm

My thinking is that offline log viewer should be allowed to evolve separately from the rest of the codebase and a newer log viewer should always be able to read older data. This is what this commit achieves.

The only exception at this moment is when compat_version is bumped. To support reading older logs after that point we will need to provide multiple read_type implementations somehow. One for each compat_version.

Nice, makes sense. There's probably a mostly mechanical refactor lurking there somewhere; good to know it's not critical based on today's serde landscape. Thanks for the explanation 🙂

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.

3 participants