vitessio / vitess

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

Fix errant GTID detection in VTOrc to also work with a replica not connected to any primary #17267

Open GuptaManan100 opened 1 day ago

GuptaManan100 commented 1 day ago

Description

As pointed out in https://github.com/vitessio/vitess/issues/17254, there is a case where VTOrc is unable to detect errant GTIDs on a tablet that got demoted.

The underlying cause of the problem was that VTOrc was not running errant GTID detection for tablets that weren't connected to any primary. Previously it would fix the replication on the tablet first and then run errant GTID detection eventually to figure out if it had errant GTIDs. However, ever since we made the vttablets also run errant GTID detection on reparent (https://github.com/vitessio/vitess/pull/16833), VTOrc is unsuccessful in reparenting the tablet with errant GTIDs since the vttablets fail with an error.

The fix is to augment VTOrc to run errant GTID detection with the primary tablet that it would reparent the replica to. There is only one special case that we need to handle which is that of the new primary's information not being advanced enough. Since VTOrc gathers information in a polling fashion, it is possible that the shard record in its data store points to the new primary, but the data collected from the new primary is older than when the promotion happened. If we use this information for errant GTID detection, we will end up marking the wrong GTIDs as errant. This situation is, however, easy to detect. We do so by checking if the primary's record has a source of its own or not. If it doesn't then the information has to have been gathered after it was promoted.

Related Issue(s)

Checklist

Deployment Notes

vitess-bot[bot] commented 1 day 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 23 hours ago

Codecov Report

Attention: Patch coverage is 87.50000% with 5 lines in your changes missing coverage. Please review.

Project coverage is 67.39%. Comparing base (c5d0ecc) to head (916e97f). Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtorc/inst/instance_dao.go 87.50% 5 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #17267 +/- ## ========================================== + Coverage 67.37% 67.39% +0.02% ========================================== Files 1573 1573 Lines 253110 253126 +16 ========================================== + Hits 170535 170598 +63 + Misses 82575 82528 -47 ```

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


🚨 Try these New Features: