{"record":{"id":"2fe1f44bcc54850b","repo":"vitessio/vitess","slug":"can-t-get-charset-to-check-binlog-stream-v","errorCode":null,"errorMessage":"can't get charset to check binlog stream: %v","messagePattern":"can't get charset to check binlog stream: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/binlog/binlog_streamer.go","lineNumber":204,"sourceCode":"\t\tlog.Info(fmt.Sprintf(\"stream ended @ %v, err = %v\", stopPos, err))\n\t}()\n\n\tif bls.conn, err = NewBinlogConnection(bls.cp); err != nil {\n\t\treturn err\n\t}\n\tdefer bls.conn.Close()\n\n\t// Check that the default charsets match, if the client specified one.\n\t// Note that Streamer uses the settings for the 'dba' user, while\n\t// BinlogPlayer uses the 'filtered' user, so those are the ones whose charset\n\t// must match. Filtered replication should still succeed even with a default\n\t// mismatch, since we pass per-statement charset info. However, Vitess in\n\t// general doesn't support servers with different default charsets, so we\n\t// treat it as a configuration error.\n\tif bls.clientCharset != nil {\n\t\tcs, err := mysql.GetCharset(bls.conn.Conn)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"can't get charset to check binlog stream: %v\", err)\n\t\t}\n\t\tlog.Info(fmt.Sprintf(\"binlog stream client charset = %v, server charset = %v\", bls.clientCharset, cs))\n\t\tif !proto.Equal(cs, bls.clientCharset) {\n\t\t\treturn fmt.Errorf(\"binlog stream client charset (%v) doesn't match server (%v)\", bls.clientCharset, cs)\n\t\t}\n\t}\n\n\tvar events <-chan mysql.BinlogEvent\n\tvar errs <-chan error\n\tif bls.timestamp != 0 {\n\t\t// MySQL 5.6 only: We are going to start reading the\n\t\t// logs from the beginning of a binlog file. That is\n\t\t// going to send us the PREVIOUS_GTIDS_EVENT that\n\t\t// contains the starting GTIDSet, and we will save\n\t\t// that as the current position.\n\t\tbls.usePreviousGTIDs = true\n\t\tevents, errs, err = bls.conn.StartBinlogDumpFromBinlogBeforeTimestamp(ctx, bls.timestamp)\n\t} else if !bls.startPos.IsZero() {","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/binlog_streamer.go#L186-L222","documentation":"Streamer.Stream wraps a failure from mysql.GetCharset when it tries to read the MySQL server's default charset at the start of a binlog dump. Vitess requires the binlog-streaming client charset to match the server default, and if the server's charset cannot even be queried (via the dba connection), the stream is aborted. The inner error is the underlying protocol/query failure.","triggerScenarios":"Calling Stream (via StreamKeyRange or StreamTables) with a non-nil clientCharset where the dba connection to MySQL cannot answer the charset query — e.g. connection dropped just after connect, server refuses the metadata query, or an unsupported/failing server returns a protocol error.","commonSituations":"MySQL server restarted or failing mid-handshake; proxy/firewall killing the dba connection; older or non-MySQL servers that don't implement the charset metadata query Vitess uses; transient network errors at stream startup.","solutions":["Check connectivity of the dba user/connection to the MySQL server and retry the stream","Look at the wrapped inner error (%v) to identify the actual protocol/query failure and fix that root cause","Verify the MySQL server version is one supported by Vitess's mysql client (supports the charset query)","If the server is healthy, enable retry of the binlog stream at a higher level (vttablet's service restarts)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before streaming, verify the dba connection can report charset\ncs, err := mysql.GetCharset(conn.Conn)\nif err != nil {\n\t// retry connect / check server health before calling Stream\n}","typeGuard":null,"tryCatchPattern":"err := streamer.Stream(ctx)\nif err != nil && strings.Contains(err.Error(), \"can't get charset to check binlog stream\") {\n\t// transient connection issue: reconnect and retry Stream\n}","preventionTips":["Ensure the dba user connection to MySQL is healthy before starting streams","Monitor MySQL server availability from vttablet","Use supported MySQL versions","Rely on vttablet's automatic stream restart for transient failures"],"tags":["mysql","binlog","charset","connection"],"backgroundTag":"mysql-charset-query-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}