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

ccl/sqlproxyccl: update PeekMsg to return message size instead of body size #76562

Merged

Conversation

jaylim-crl
Copy link
Collaborator

Informs #76000. Follow-up to #76006.

Previously, PeekMsg was returning the body size (excluding header size), which
is a bit awkward from an API point of view because most callers of PeekMsg
immediately adds the header size to the returned size previously. This commit
cleans the API design up by making PeekMsg return the message size instead,
i.e. header inclusive. At the same time, returning the message size makes it
consistent with the ReadMsg API since that returns the entire message.

Release note: None

@jaylim-crl jaylim-crl requested a review from a team as a code owner February 15, 2022 04:02
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@jeffswenson jeffswenson left a comment

Choose a reason for hiding this comment

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

LGTM

pkg/ccl/sqlproxyccl/interceptor/base.go Show resolved Hide resolved
…y size

Informs cockroachdb#76000. Follow-up to cockroachdb#76006.

Previously, PeekMsg was returning the body size (excluding header size), which
is a bit awkward from an API point of view because most callers of PeekMsg
immediately adds the header size to the returned size previously. This commit
cleans the API design up by making PeekMsg return the message size instead,
i.e. header inclusive. At the same time, returning the message size makes it
consistent with the ReadMsg API since that returns the entire message.

Release note: None
@jaylim-crl jaylim-crl force-pushed the jay/update-peek-api-pginterceptor branch from d6348f2 to 2dfd748 Compare February 15, 2022 15:55
Copy link
Collaborator Author

@jaylim-crl jaylim-crl left a comment

Choose a reason for hiding this comment

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

TFTR!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andy-kimball)


pkg/ccl/sqlproxyccl/interceptor/base.go, line 113 at r1 (raw file):

Previously, JeffSwenson (Jeff Swenson) wrote…

nit: Adding 1 can overflow size into a negative number. change the ErrProtocolError condition to:

if size < 4 || size == math.MaxInt {
return 0, 0, ErrProtocolError
}

This is a good catch. I checked on math.MaxInt32 instead since the data came from 4 bytes. Also added a test case for that.

@jaylim-crl
Copy link
Collaborator Author

bors r=JeffSwenson

@craig
Copy link
Contributor

craig bot commented Feb 15, 2022

Build succeeded:

@craig craig bot merged commit 3cb7eb0 into cockroachdb:master Feb 15, 2022
@jaylim-crl jaylim-crl deleted the jay/update-peek-api-pginterceptor branch February 15, 2022 19:52
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