Skip to content

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

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
jaylim-crl:jay/update-peek-api-pginterceptor
Feb 15, 2022
Merged

ccl/sqlproxyccl: update PeekMsg to return message size instead of body size#76562
craig[bot] merged 1 commit intocockroachdb:masterfrom
jaylim-crl:jay/update-peek-api-pginterceptor

Conversation

@jaylim-crl
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
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

…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
Copy Markdown
Contributor 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
Copy Markdown
Contributor Author

bors r=JeffSwenson

@craig
Copy link
Copy Markdown
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