Skip to content

rpk/serde: replace hamba/avro and linkedin/goavro with twmb/avro#29983

Merged
r-vasquez merged 1 commit intoredpanda-data:devfrom
r-vasquez:avro-migration
Apr 9, 2026
Merged

rpk/serde: replace hamba/avro and linkedin/goavro with twmb/avro#29983
r-vasquez merged 1 commit intoredpanda-data:devfrom
r-vasquez:avro-migration

Conversation

@r-vasquez
Copy link
Copy Markdown
Contributor

@r-vasquez r-vasquez commented Mar 27, 2026

Continuation of #29845 ...

Replace the two separate avro libraries (hamba/avro for schema reference resolution, linkedin/goavro for encoding/decoding) with the single twmb/avro library, which handles both.

This changes union serialization behavior: linkedin/goavro used Avro-JSON encoding where unions are serialized as {"type": value} objects. twmb/avro marshals union values as the bare type directly. Similarly for deserialization, we will no longer read the old {"type": value} union form but instead expect the value directly.

Schema reference resolution now uses an explicit SchemaCache rather than relying on hamba/avro's implicit global cache. This also removes the replace directive for the redpanda-data/go-avro fork.

(cherry picked from commit 59dcf96)

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
  • v26.1.x
  • v25.3.x
  • v25.2.x

Release Notes

  • none

@r-vasquez
Copy link
Copy Markdown
Contributor Author

/dt

@r-vasquez r-vasquez marked this pull request as ready for review April 9, 2026 16:43
@r-vasquez r-vasquez requested review from a team and kbatuigas as code owners April 9, 2026 16:43
@r-vasquez r-vasquez requested review from Copilot and graham-rp and removed request for a team April 9, 2026 16:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Replaces the existing split Avro implementation in rpk (hamba/avro for reference resolution + linkedin/goavro for encode/decode) with a single implementation based on twmb/avro, updating both the Go module dependencies and Bazel deps accordingly.

Changes:

  • Switch Avro encode/decode to use github.com/twmb/avro schemas (Encode/Decode) and JSON marshal/unmarshal.
  • Implement explicit schema reference resolution via avro.SchemaCache (instead of relying on hamba/avro’s implicit global cache).
  • Update Go/Bazel dependency graphs to remove hamba/avro + goavro and add twmb/avro.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/go/rpk/pkg/serde/serde.go Wires NewSerde to use the new compiled *avro.Schema for Avro serdes.
src/go/rpk/pkg/serde/BUILD Replaces Bazel deps for Avro from hamba/goavro to twmb/avro.
src/go/rpk/pkg/serde/avro.go Reimplements Avro encode/decode and reference parsing using twmb/avro and SchemaCache.
src/go/rpk/go.mod Drops hamba/goavro + replace directive, adds github.com/twmb/avro.
src/go/rpk/go.sum Updates sums consistent with the dependency switch (including removing old Avro libs).
MODULE.bazel Updates bzlmod use_repo entries to remove old Avro repos and add com_github_twmb_avro.

Comment thread src/go/rpk/pkg/serde/avro.go
Comment thread src/go/rpk/pkg/serde/avro.go Outdated
Comment thread src/go/rpk/pkg/serde/avro.go Outdated
Comment thread src/go/rpk/pkg/serde/avro.go Outdated
Comment thread src/go/rpk/pkg/serde/avro.go
Copy link
Copy Markdown
Contributor

@graham-rp graham-rp left a comment

Choose a reason for hiding this comment

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

Agreed with copilot about a test for union encoding, but looks good otherwise

c-julin
c-julin previously approved these changes Apr 9, 2026
Replace the two separate avro libraries (hamba/avro for schema reference
resolution, linkedin/goavro for encoding/decoding) with the single
twmb/avro library, which handles both.

This changes union serialization output: decoded union values are now
written as bare JSON values rather than the Avro-JSON {"type": value}
form used by linkedin/goavro. The encoder accepts both formats as input.
Encoding and decoding now use twmb/avro's schema-aware DecodeJSON and
EncodeJSON methods, which preserve full int64 precision for Avro long
fields (json.Unmarshal loses precision beyond 2^53).

Schema reference resolution now uses an explicit SchemaCache rather than
relying on hamba/avro's implicit global cache. This also removes the
replace directive for the redpanda-data/go-avro fork.

(cherry picked from commit 59dcf96)
@vbotbuildovich
Copy link
Copy Markdown
Collaborator

Retry command for Build#82959

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

/ci-repeat 1
skip-redpanda-build
skip-units
skip-rebase
tests/rptest/tests/cloud_topics/debug_rows_test.py::DebugRowsTest.test_validate_partition

@vbotbuildovich
Copy link
Copy Markdown
Collaborator

CI test results

test results on build#82959
test_status test_class test_method test_arguments test_kind job_url passed reason test_history
FLAKY(FAIL) DebugRowsTest test_validate_partition null integration https://buildkite.com/redpanda/redpanda/builds/82959#019d7371-e10d-4203-bf99-974a5460f049 8/11 Test FAILS after retries.Significant increase in flaky rate(baseline=0.0149, p0=0.0093, reject_threshold=0.0100) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=DebugRowsTest&test_method=test_validate_partition
FLAKY(PASS) WriteCachingFailureInjectionE2ETest test_crash_all {"use_transactions": false} integration https://buildkite.com/redpanda/redpanda/builds/82959#019d7371-e10e-4ffc-87b6-f236a95354bc 9/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0753, p0=0.5427, reject_threshold=0.0100. adj_baseline=0.2092, p1=0.3486, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=WriteCachingFailureInjectionE2ETest&test_method=test_crash_all

@r-vasquez
Copy link
Copy Markdown
Contributor Author

/ci-repeat 1
skip-redpanda-build
skip-units
skip-rebase
tests/rptest/tests/cloud_topics/debug_rows_test.py::DebugRowsTest.test_validate_partition

@r-vasquez r-vasquez enabled auto-merge April 9, 2026 20:26
@r-vasquez r-vasquez merged commit 5a3c07c into redpanda-data:dev Apr 9, 2026
22 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants