{"record":{"id":"a8e2ef30a76204cf","repo":"risingwavelabs/risingwave","slug":"failed-to-get-mysql-version","errorCode":null,"errorMessage":"Failed to get MySQL version","messagePattern":"Failed to get MySQL version","errorType":"exception","errorClass":"ConnectorError","httpStatus":null,"severity":"error","filePath":"src/connector/src/source/cdc/external/mysql.rs","lineNumber":545,"sourceCode":"    /// Get MySQL version from the connection\n    async fn get_mysql_version(pool: &mysql_async::Pool) -> ConnectorResult<(u8, u8, bool)> {\n        let mut conn = pool.get_conn().await?;\n        let result: Option<String> = conn.query_first(\"SELECT VERSION()\").await?;\n\n        if let Some(version_str) = result {\n            let parts: Vec<&str> = version_str.split('.').collect();\n            if parts.len() >= 2 {\n                let major_version = parts[0]\n                    .parse::<u8>()\n                    .context(\"Failed to parse major version\")?;\n                let minor_version = parts[1]\n                    .parse::<u8>()\n                    .context(\"Failed to parse minor version\")?;\n                let is_mariadb = version_str.to_lowercase().contains(\"mariadb\");\n                return Ok((major_version, minor_version, is_mariadb));\n            }\n        }\n        Err(anyhow!(\"Failed to get MySQL version\").into())\n    }\n\n    /// Check if MySQL version is 8.4 or later\n    fn is_mysql_8_4_or_later(&self) -> bool {\n        let (major, minor) = self.mysql_version;\n        major > 8 || (major == 8 && minor >= 4)\n    }\n\n    pub async fn new(\n        config: ExternalTableConfig,\n        rw_schema: Schema,\n        pk_indices: Vec<usize>,\n    ) -> ConnectorResult<Self> {\n        let database = config.database.clone();\n        let table = config.table.clone();\n        let pool = build_mysql_connection_pool(\n            &config.host,\n            config.port.parse::<u16>().unwrap(),","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/source/cdc/external/mysql.rs#L527-L563","documentation":"get_mysql_version queries `SELECT VERSION()` and parses the string; if the query succeeds but no parseable `x.y...` version token is found, it returns this error. The reader needs the version (and MariaDB detection) for capability checks like mysql_native_password vs. caching_sha2 behavior.","triggerScenarios":"MySqlExternalTableReader::connect runs get_mysql_version and the server returns a VERSION() string that does not match the expected `major.minor[.patch]` prefix pattern, or the result set is empty.","commonSituations":"Pointing CDC at MySQL-compatible services (ProxySQL in front, Vitess, TiDB, unusual forks) that return nonstandard VERSION() strings; permission issues yielding empty results.","solutions":["Check what `SELECT VERSION()` returns on the target server and confirm it starts with a numeric version like '8.0.32'.","Bypass or reconfigure proxies that rewrite the VERSION string.","Upgrade the connector to handle the fork's version format, or pin a standard MySQL/MariaDB version for CDC.","Verify the CDC user has permission to execute SELECT on the server (VERSION() is generally unrestricted, but proxies may block it)."],"exampleFix":"// before (proxy returns \"mysql-advanced 8\")\n// after: fix VERSION() output or make parsing lenient\nlet version_str = /* row value */;\nlet Some((major, rest)) = version_str.split_once('.') else {\n    return Err(anyhow!(\"Failed to get MySQL version: '{}'\".to_string(), version_str).into());\n};","handlingStrategy":"try-catch","validationCode":"// Sanity-check the target server before connecting CDC:\nlet version: String = sqlx::query_scalar(\"SELECT VERSION()\").fetch_one(&conn).await?;\nif !version.chars().next().map_or(false, |c| c.is_ascii_digit()) {\n    return Err(format!(\"server VERSION() is non-standard: {}\", version));\n}","typeGuard":"fn is_parsable_mysql_version(v: &str) -> bool {\n    let mut parts = v.split('.');\n    parts.next().map_or(false, |m| m.chars().all(|c| c.is_ascii_digit()) && !m.is_empty())\n        && parts.next().map_or(false, |m| m.chars().all(|c| c.is_ascii_digit()) && !m.is_empty())\n}","tryCatchPattern":"match connect_mysql_external_table(cfg).await {\n    Err(e) if e.to_string().contains(\"Failed to get MySQL version\") => {\n        eprintln!(\"Check `SELECT VERSION()` output on the server/proxy: it must start with 'major.minor'\");\n        Err(e)\n    }\n    other => other,\n}","preventionTips":["Run `SELECT VERSION()` on the target before CDC setup and verify it starts with a numeric version.","Avoid proxies/forks that rewrite VERSION().","Test CDC connectivity against the exact server version in staging.","Retry with a direct connection if a proxy is suspected."],"tags":["cdc","mysql","version-detection","compatibility"],"backgroundTag":"unexpected-response-shape","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}