Skip to content

Switching to diesel-async broke use of the connection parameter ?unix_socket= #1843

@kyz

Description

@kyz

Commit 192d64c switched to using diesel-async.

The code establishing MySQL connections switched from MysqlConnection::establish to AsyncMysqlConnection::establish

MysqlConnection::establish supports connection strings in the form mysql://[user[:password]@]host/database_name[?unix_socket=socket-path&ssl_mode=SSL_MODE*&ssl_ca=/etc/ssl/certs/ca-certificates.crt&ssl_cert=/etc/ssl/certs/client-cert.crt&ssl_key=/etc/ssl/certs/client-key.crt]

AsyncMysqlConnection::establish only supports connection strings in the form mysql://[user[:password]@]host/database_name

My connection string looks like syncstorage.database_url = "mysql://syncstorage:PASSWORD@localhost/syncstorage_rs?unix_socket=/run/mysqld/mysqld.sock" -- I use the unix_socket connection because it's more reliable and faster than using TCP connections

syncserver immediately fails with an error:

thread 'main' panicked at syncserver/src/main.rs:63:55:
called `Result::unwrap()` on an `Err` value: ApiError { kind: Db(DbError { kind: Mysql(SqlError { kind: DieselConnection(InvalidConnectionUrl("Unknown connection URL parameter `unix_socket'")), status: 500, backtrace:    0: <syncserver_db_common::error::SqlError as core::convert::From<syncserver_db_common::error::SqlErrorKind>>::from
             at /home/pkgbuild/syncserver/syncstorage-rs/syncserver-db-common/src/error.rs:34:24
   1: <T as core::convert::Into<U>>::into
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/convert/mod.rs:784:9
   2: <syncserver_db_common::error::SqlError as core::convert::From<diesel::result::ConnectionError>>::from
             at /home/pkgbuild/syncserver/syncstorage-rs/syncserver-common/src/lib.rs:50:33
   3: <syncstorage_mysql::error::DbError as core::convert::From<diesel::result::ConnectionError>>::from::{{closure}}
             at /home/pkgbuild/syncserver/syncstorage-rs/syncstorage-mysql/src/error.rs:160:79
   4: <syncstorage_mysql::error::DbError as core::convert::From<diesel::result::ConnectionError>>::from
             at /home/pkgbuild/syncserver/syncstorage-rs/syncserver-common/src/lib.rs:50:17
   5: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/result.rs:2087:27
   6: syncstorage_mysql::pool::run_embedded_migrations
             at /home/pkgbuild/syncserver/syncstorage-rs/syncstorage-mysql/src/pool.rs:46:16
   7: <syncstorage_mysql::pool::MysqlDbPool as syncstorage_db_common::DbPool>::init::{{closure}}::{{closure}}
             at /home/pkgbuild/syncserver/syncstorage-rs/syncstorage-mysql/src/pool.rs:163:32

My only workaround is to remove ?unix_socket=/run/mysqld/mysqld.sock from my connection strings. syncserver works fine then, albeit with slower DB performance.

┆Issue is synchronized with this Jira Task

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions