vitessio / vitess

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

Handle MySQL handler error codes #17252

Closed shlomi-noach closed 5 days ago

shlomi-noach commented 6 days ago

Description

Some of MySQL errors include more fine grained handler error codes, as seen in

bld/include/mysqld_ername.h:205:{ "ER_ERROR_DURING_COMMIT", 1180, "Got error %d - \'%-.192s\' during COMMIT","HY000", "", 162 },

For example: ERROR HY000: Got error 149 - 'Lock deadlock; Retry transaction' during COMMIT

Another example: ER_ERROR_DURING_COMMIT as described in https://github.com/vitessio/vitess/issues/17248.

With this PR we formally introduce HandlerErrorCode. We add SQLError.HaErrorCode() which uses regexp parsing on the error message to extract the handler error code, if any.

Furthermore, some of these handler error codes indicate an unrecoverable error for vreplication. We meanwhile add a sample of those. We list the full range of existing HA errors, and mark a select few as recoverable.

Related Issue(s)

https://github.com/vitessio/vitess/issues/17248

Checklist

Deployment Notes

vitess-bot[bot] commented 6 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 6 days ago

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.

Project coverage is 67.42%. Comparing base (216fd70) to head (cb99a24). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
go/mysql/sqlerror/constants.go 0.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #17252 +/- ## ========================================== + Coverage 67.39% 67.42% +0.02% ========================================== Files 1570 1570 Lines 252917 252934 +17 ========================================== + Hits 170446 170529 +83 + Misses 82471 82405 -66 ```

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


🚨 Try these New Features: