rpk: fix concurrent map writes in proto serde encodefn#26619
rpk: fix concurrent map writes in proto serde encodefn#26619r-vasquez merged 2 commits intoredpanda-data:devfrom
Conversation
When serde.EncodeRecord is called on a cached serde function across multiple goroutines, dynamicpb.Set panics with a concurrent map writes fatal. This is caused by the message previously being created outside of the returned encodefn and attempting to unmarshal the byte slice on the same dynamicpb message. While not an issue for rpk per-se, if this package is imported into another project which does attempt concurrent encodes, this fails. By moving the creation of the dynamicpb object inside the returned encodefn, it does not impact the performance of rpk but allows concurrent encoding to happen if other packages chose to import it.
|
|
r-vasquez
left a comment
There was a problem hiding this comment.
Good catch, thanks for the PR.
Retry command for Build#68124please wait until all jobs are finished before running the slash command |
CI test resultstest results on build#68124
test results on build#68364
|
|
I am unable to see the results of the failed build to verify it is not my test that is flakey in CI. Let me know if I need to make any modifications. |
|
@hunterjm Sorry, I was out this week and didn't check the last CI jobs. I just approved the CI workflow. I'll check for failures and report back once it's done. There is no need to rebase for now unless there is an issue. thanks! |
|
/backport v25.1.x |
|
Failed to create a backport PR to v25.1.x branch. I tried: |
When serde.EncodeRecord is called on a cached serde function across multiple goroutines,
dynamicpb.Setpanics with a concurrent map writes fatal. This is caused by the message previously being created outside of the returned encodefn and attempting to unmarshal the byte slice on the same dynamicpb message.While not an issue for rpk per-se, if this package is imported into another project which does attempt concurrent encodes, this fails. By moving the creation of the dynamicpb object inside the returned encodefn, it does not impact the performance of rpk but allows concurrent encoding to happen if other packages chose to import it.
Backports Required
Release Notes