pingcap / pingcap/tiproxy

TiProxy is incompatible with go-sql-driver 1.3.0

Open
#325 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

wontfix
Dominant language
Go
Stars
73
Forks
41
Avg merge
21h 3m
Merged PRs (30d)
21

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)
  1. Start TiDB and TiProxy
  2. Connect to TiProxy with go 1.3.0
import (
	"database/sql"
	_ "github.com/go-sql-driver/mysql"
)

func main() {
	mdb, err := sql.Open("mysql", "root@tcp(localhost:6001)/test")
	if err != nil {
		panic(err)
	}
	err = mdb.Ping()
	if err != nil {
		panic(err)
	}
}
2. What did you expect to see? (Required)

No error

3. What did you see instead (Required)

Driver reports this user requires mysql native password authentication.

4. What is your version? (Required)

master.

The reason:

  • Go-sql-driver sends the auth packet with mysql_native_password. But when TiProxy requests to switch auth method to mysql_native_password, go-sql-driver just reports ErrNativePassword. See https://github.com/go-sql-driver/mysql/blob/v1.3.0/packets.go#L495-L497. I think there's no way to avoid this problem on TiProxy side.
  • Connecting to TiDB directly doesn't have this problem because TiDB won't send a switch auth request in this case.
  • Go-sql-driver 1.4.0 works well.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure by starting TiDB and TiProxy, then connecting with go-sql-driver/mysql 1.3.0 using the example in the issue. Read go-sql-driver/mysql v1.3.0 packets.go around lines 495-497 and compare the authentication handshake with version 1.4.0; done means the compatibility problem and a project-owned fix path are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, mysql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.