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

Vindexes: Pass context in consistent lookup handleDup #14653

Conversation

brendar
Copy link
Contributor

@brendar brendar commented Dec 1, 2023

Description

Context handling was refactored in c43a162 which included this TODO

// TODO: context needs to be passed on.
qr, err = vcursor.ExecuteKeyspaceID(context.Background(), lu.keyspace, existingksid, lu.lockOwnerQuery, bindVars, false /* rollbackOnError */, false /* autocommit */)

This causes consistent lookup duplicate row handling to fail when tablets are using strict table ACL enforcement because there is no caller id in the context.

It looks like the TODO and context.Background() was left behind inadvertently, so this PR simply passes the existing context through. cc @harshit-gangal in case there was a reason for it.

Related Issue(s)

Fixes #14652

Checklist

  • "Backport to:" labels have been added if this change should be back-ported
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on the CI
  • Documentation was added or is not required

Deployment Notes

n/a

Copy link
Contributor

vitess-bot bot commented Dec 1, 2023

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Dec 1, 2023
@github-actions github-actions bot added this to the v19.0.0 milestone Dec 1, 2023
@shlomi-noach shlomi-noach added Type: Bug Component: Query Serving and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request labels Dec 4, 2023
@shlomi-noach
Copy link
Contributor

Is it possible to add a unit test that verifies the new behavior?

@brendar
Copy link
Contributor Author

brendar commented Dec 19, 2023

Is it possible to add a unit test that verifies the new behavior?

I could update the consistent lookup unit tests in go/vt/vtgate/vindexes/consistent_lookup_test.go to assert that the same context is used for all queries, or I could update the vtgate lookup endtoend tests to use table ACLs by configuring them in go/test/endtoend/vtgate/main_test.go.

Either way would catch the bug and verify the fix. Do you have a preference? I'm not sure if the project has strong opinions about testing the implementation vs testing the behavior.

@shlomi-noach
Copy link
Contributor

I'm not sure if the project has strong opinions about testing the implementation vs testing the behavior.

Haha there's differing opinions her as well. But the general agreement is that unit testing is more predictable, less flaky, easier to debug. Also, at the end of the day, "why not both?"

@brendar
Copy link
Contributor Author

brendar commented Dec 19, 2023

I've updated the unit tests for consistent lookup vindexes to ensure they're passing the expected context whenever they execute a query.

I didn't update the vtgate endtoend tests to use table ACLs since it would apply to all tests in that package. The tests still pass, but it could make debugging other issues more complicated. Happy to add that if you think it's worth doing.

@brendar
Copy link
Contributor Author

brendar commented Dec 20, 2023

Would it be possible to add backport labels to this PR? The bug presents a slight MySQL compatibility issue for clients in that they can't catch and recover from the expected duplicate entry error code 1062, so I think backporting it would be nice.

@shlomi-noach
Copy link
Contributor

@harshit-gangal for backport consideration

@dbussink dbussink merged commit 6f23f60 into vitessio:main Jan 8, 2024
116 checks passed
harshit-gangal pushed a commit to planetscale/vitess that referenced this pull request Jan 9, 2024
harshit-gangal pushed a commit to planetscale/vitess that referenced this pull request Jan 9, 2024
frouioui pushed a commit that referenced this pull request Jan 9, 2024
frouioui pushed a commit that referenced this pull request Jan 9, 2024
brendar added a commit to Shopify/vitess that referenced this pull request Jan 16, 2024
brendar added a commit to Shopify/vitess that referenced this pull request Jan 16, 2024
…r-id-error-with-consistent-lookup-vindexes

Backport: Vindexes: Pass context in consistent lookup handleDup (vitessio#14653)
shanth96 pushed a commit to Shopify/vitess that referenced this pull request Feb 20, 2024
shanth96 pushed a commit to Shopify/vitess that referenced this pull request Feb 20, 2024
shanth96 pushed a commit to Shopify/vitess that referenced this pull request Mar 20, 2024
…r-id-error-with-consistent-lookup-vindexes

Backport: Vindexes: Pass context in consistent lookup handleDup (vitessio#14653)
shanth96 pushed a commit to Shopify/vitess that referenced this pull request Mar 20, 2024
…r-id-error-with-consistent-lookup-vindexes

Backport: Vindexes: Pass context in consistent lookup handleDup (vitessio#14653)
(cherry picked from commit aacae86)
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.

Bug Report: consistent_lookup_unique vindex returns "missing caller id" error instead of duplicate entry error
4 participants