Skip to content

MySQL Replication Job Not Using Correct MySQL Port #238

@joshuagauci

Description

@joshuagauci

There is a bug in BinLogReplicationJob.ts where the poolOptions are not using the same port as the original MySQL connection. This causes connection failures when trying to replicate MySQL data.

Steps to Reproduce:

Configure PowerSync to connect to a MySQL database on port 25060.

Run the replication job.

Observe that while the main MySQL connection is correctly using port 25060, the pool connections are defaulting to 3306.

The connection fails due to the incorrect port.

Expected Behavior:
The connection pool should inherit the port from the original MySQL connection configuration, ensuring that all connections use 25060 instead of the default 3306.

Actual Behavior:

The main connection is correctly using port 25060.

However, poolOptions default to 3306, causing connection timeouts and replication failures.

Tested Workaround:
I manually set the port in the connection factory configuration as follows:

const connectionManager = this.connectionFactory.create({
idleTimeout: 30_000,
port: 25060 // Manually setting the correct port
});

With this change, PowerSync was able to connect, but replication did not complete due to another connection timeout, which also defaulted to port 3306.

Logs:

Connection Manager {"binlogListeners":[],"isClosed":false,"name":"ReplicationJob: mysql-demo-1","options":{"database":"demo","hostname":"test.url.com","id":"default","password":"testpassword","port":25060,"server_id":1,"tag":"default","type":"mysql","uri":"mysql://test:[email protected]:25060/demo","username":"test"},"pool":{"config":{"connectionConfig":{"port":3306}}}}
PowerSync Connection Configuration:

replication:
  connections:
    - type: mysql
      uri: mysql://test:[email protected]:25060/demo

or

replication:
  connections:
    - type: mysql
      uri: mysql://test:[email protected]/demo:25060
      port: 25060

Temporary Workaround:

Setup a stream relay using socat to proxy port 3306 to 25060.

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