From 789a03fcb5c5c05557fc4894ba4b6b0ddfcd554b Mon Sep 17 00:00:00 2001 From: abcpro1 Date: Fri, 15 Sep 2023 14:33:45 +0000 Subject: [PATCH] fix: mysql use a random server_id if none was specified MySQL returns an error if two clients are using the same `server_id` concurrently. --- dozer-ingestion/src/connectors/mysql/connector.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dozer-ingestion/src/connectors/mysql/connector.rs b/dozer-ingestion/src/connectors/mysql/connector.rs index 8a217f878f..96c000c9c3 100644 --- a/dozer-ingestion/src/connectors/mysql/connector.rs +++ b/dozer-ingestion/src/connectors/mysql/connector.rs @@ -20,6 +20,7 @@ use dozer_types::{ }; use mysql_async::{Opts, Pool}; use mysql_common::Row; +use rand::Rng; #[derive(Debug)] pub struct MySQLConnector { @@ -378,7 +379,7 @@ impl MySQLConnector { start_position: BinlogPosition, stop_position: Option, ) -> Result<(), ConnectorError> { - let server_id = self.server_id.unwrap_or(0xd07e5); + let server_id = self.server_id.unwrap_or_else(|| rand::thread_rng().gen()); let mut binlog_ingestor = BinlogIngestor::new( ingestor,