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

Making Reshard work smoothly with Atomic Transactions #16844

Merged
merged 10 commits into from
Oct 3, 2024

Conversation

GuptaManan100
Copy link
Member

@GuptaManan100 GuptaManan100 commented Sep 25, 2024

Description

This PR makes the changes required to make Reshard work with Atomic transactions. Before these changes, Resharding won't wait for prepared atomic transactions to go through, and we could be in a situation where a prepared transaction is unable to commit on the source shards because we have stopped query service on it. At the same time, that prepared transaction won't exist on the target shards, leading to us being unable to commit a prepared transaction altogether.

This PR fixes this situation by changing the RefreshState RPC that Resharding is using. Now, when vttablet is executing the RefreshState RPC, if it decides that query service needs to be stopped, it first turns off the two pc engine from accepting new prepared transactions and then waits for the current prepared transactions until they're resolved. This ensures Resharding doesn't proceed until all the prepared transactions have concluded.

This PR adds fuzzer and stress tests to verify that the changes work as intended. The changes in this PR are different from the ones proposed in the RFC #16245 (comment), because we found that this solution is more elegant and easier to implement than the one proposed there.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Copy link
Contributor

vitess-bot bot commented Sep 25, 2024

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 NeedsBackportReason If backport labels have been applied to a PR, a justification is required 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 Sep 25, 2024
@github-actions github-actions bot added this to the v21.0.0 milestone Sep 25, 2024
@GuptaManan100 GuptaManan100 added Type: Enhancement Logical improvement (somewhere between a bug and feature) 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 NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Sep 27, 2024
Copy link

codecov bot commented Sep 27, 2024

Codecov Report

Attention: Patch coverage is 67.74194% with 20 lines in your changes missing coverage. Please review.

Project coverage is 69.43%. Comparing base (766bc64) to head (85c1c34).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vttablet/tabletserver/tabletserver.go 20.00% 12 Missing ⚠️
go/vt/vttablet/tabletmanager/rpc_replication.go 0.00% 3 Missing ⚠️
go/vt/vttablet/tabletmanager/tm_init.go 57.14% 3 Missing ⚠️
go/vt/vttablet/tabletmanager/tm_state.go 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16844      +/-   ##
==========================================
- Coverage   69.43%   69.43%   -0.01%     
==========================================
  Files        1571     1571              
  Lines      203086   203239     +153     
==========================================
+ Hits       141013   141113     +100     
- Misses      62073    62126      +53     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Manan Gupta <[email protected]>
Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps left a comment

Choose a reason for hiding this comment

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

Elegant solution!

Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

LGTM. I only had some minor nits, requests, suggestions. Nice work on this, @GuptaManan100 !

go/test/endtoend/transaction/twopc/fuzz/fuzzer_test.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletmanager/tm_init.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletserver/controller.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletserver/tabletserver.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletserver/tabletserver.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletserver/tx_engine.go Show resolved Hide resolved
go/vt/vttablet/tabletserver/tx_engine.go Outdated Show resolved Hide resolved
go/vt/vttablet/tabletserver/tx_engine.go Show resolved Hide resolved
go/vt/vttablet/tabletserver/tx_prep_pool.go Show resolved Hide resolved
@GuptaManan100
Copy link
Member Author

Thank you for the reviews everyone! 🚀 I've addressed the review comments and am merging the PR now.

@GuptaManan100 GuptaManan100 merged commit 24212e7 into vitessio:main Oct 3, 2024
98 checks passed
@GuptaManan100 GuptaManan100 deleted the reshard-atomic-transactions branch October 3, 2024 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: Atomic Distributed Transactions
4 participants