vitessio / vitess

Vitess is a database clustering system for horizontal scaling of MySQL.
http://vitess.io
Apache License 2.0
18.47k stars 2.09k forks source link

Making Reshard work smoothly with Atomic Transactions #16844

Open GuptaManan100 opened 3 days ago

GuptaManan100 commented 3 days ago

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 https://github.com/vitessio/vitess/issues/16245#issuecomment-2273836571, because we found that this solution is more elegant and easier to implement than the one proposed there.

Related Issue(s)

Checklist

Deployment Notes

vitess-bot[bot] commented 3 days ago

Review Checklist

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

General

Tests

Documentation

New flags

If a workflow is added or modified:

Backward compatibility

codecov[bot] commented 1 day ago

Codecov Report

Attention: Patch coverage is 70.90909% with 16 lines in your changes missing coverage. Please review.

Project coverage is 69.44%. Comparing base (3743f09) to head (d664547). Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vttablet/tabletserver/tabletserver.go 23.07% 10 Missing :warning:
go/vt/vttablet/tabletmanager/rpc_replication.go 0.00% 3 Missing :warning:
go/vt/vttablet/tabletmanager/tm_state.go 86.66% 2 Missing :warning:
go/vt/vttablet/tabletmanager/tm_init.go 75.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #16844 +/- ## ======================================== Coverage 69.44% 69.44% ======================================== Files 1571 1571 Lines 203004 203113 +109 ======================================== + Hits 140974 141052 +78 - Misses 62030 62061 +31 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.