-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix(vector source protobuf codec disk buffering) Build prost with no-recursion-limit feature #19413
Open
sbalmos
wants to merge
1
commit into
vectordotdev:master
Choose a base branch
from
sbalmos:prost_recursion
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, I am not a fan of unbounded defaults. See discussions:
A better alternative here would be to reach out to prost maintainers and ask them to expose RECURSION_LIMIT (100 seems a bit low) as a configuration option. And then we can re-expose it in our codec config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, infinite recursion could lead to runaway recursion bugs. I'd also feel better about exposing a configurable option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been looking over the code paths used, to map out what all is in play. It is not enough to get prost to expose RECURSION_LIMIT, or more likely to create a new constructor function for
DecodeContext
that takes arecurse_count
field parameter. Theprotobuf
codec usesDynamicMessage
to do decoding, which then also would have to be extended to take a client-providedDecodeContext
- the general idea being that Vector would create aDecodeContext
with the desiredrecurse_count
.However, this only handles sources/sinks using the
protobuf
codec directly. The bigger issue is that the Vector-native source/sink do not (directly) use prost at all. They operate through tonic, using compile-time stubs generated from the proto-file. All byte-stream decoding calls simply call those autogenerated stubs to decode. There are no prost calls or anywhere to potentially modify or extend to use a client-providedDecodeContext
.I can't tell what/where/how the disk buffering encoding/decoding ultimately ties into prost, to figure out that angle.
Further, a configurable recursion limit knob in the protobuf codec and in the Vector source configs would actually have two different meanings, because the proto-generated Vector-native
Event
(orEventMessage
) stubs currently have a 3-layer per decoded field recursion (Event -> Kind -> Value I believe?). This is effectively why the prost limit of 100 layers equates to a client-visible JSON recursion limit of 32/33 layers. Either documentation, or a multiplier, would have to be performed and remain in lockstep with the proto-definition of the Vector-nativeEvent
message type.I would also tend to think runaway recursion would have to first get past the max message size limits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there is some movement on making the limit configurable (at build time): tokio-rs/prost#785
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that that was a year ago 😭 Maybe someone will want to pick up that torch though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's pretty trivial to create a nested struct that is well below the message limit but with significant recursion.
I see what you are saying about the difficulties of configuring it at runtime if that was possible. I think I'd be ok with seeing a build time increase to the limit (say to 1000) but that will still require
prost
support first.