Repository: julien-duponchelle/python-mysql-replication (language: python)

Issue:
Suggestion on removal of `log_slave_updates` system variable
I am seeking understanding regarding the specification and use of the `log_slave_updates` system variable as indicated in [docker-compose.yml](https://github.com/julien-duponchelle/python-mysql-replication/blob/main/docker-compose.yml) and [scripts/install_mysql.sh](https://github.com/julien-duponchelle/python-mysql-replication/blob/main/scripts/install_mysql.sh).

The function of `log_slave_updates` is to enable a MySQL slave to log events to its binary log, as opposed to the relay log. However, python-mysql-replication does not maintain a relay or binary log, which makes the application of this variable seem inappropriate.

Considering that the python-mysql-replication operates in the capacity of a **client** rather than a slave, it should only be affected by system variables that modify how the master transmits data.

I would appreciate clarification on the rationale behind including the `log_slave_updates` system variable in the project. If no convincing reasons exist for its inclusion, I would like to suggest the **removal of this variable** for better project clarity and focus.


Discussion / hints:

Fix patch:
diff --git a/docker-compose.yml b/docker-compose.yml
index 45b53c3d..9e68758c 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,37 +1,47 @@
-version: '3.2'
+version: '3.4'
+
+x-mysql: &mysql
+  environment:
+    MYSQL_ALLOW_EMPTY_PASSWORD: true
+  command: >
+    mysqld
+    --log-bin=mysql-bin.log
+    --server-id 1
+    --binlog-format=row
+    --gtid_mode=on
+    --enforce-gtid-consistency=on
+
+x-mariadb: &mariadb
+  environment:
+    MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 1
+  command: >
+    --log-bin=master-bin
+    --server-id=1
+    --default-authentication-plugin=mysql_native_password
+    --binlog-format=row
+
 services:
   percona-5.7:
+    <<: *mysql
     image: percona:5.7
-    environment:
-      MYSQL_ALLOW_EMPTY_PASSWORD: true
     ports:
-      - 3306:3306
-    command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates
+      - "3306:3306"
 
   percona-5.7-ctl:
+    <<: *mysql
     image: percona:5.7
-    environment:
-      MYSQL_ALLOW_EMPTY_PASSWORD: true
     ports:
-      - 3307:3307
-    command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates -P 3307
+      - "3307:3306"
 
   mariadb-10.6:
+    <<: *mariadb
     image: mariadb:10.6
-    environment:
-      MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 1
     ports:
       - "3308:3306"
-    command: |
-      --server-id=1
-      --default-authentication-plugin=mysql_native_password
-      --log-bin=master-bin
-      --binlog-format=row
-      --log-slave-updates=on
     volumes:
       - type: bind
         source: ./.mariadb
         target: /opt/key_file
       - type: bind
         source: ./.mariadb/my.cnf
-        target: /etc/mysql/my.cnf  
+        target: /etc/mysql/my.cnf


Test patch:
diff --git a/docker-compose-test.yml b/docker-compose-test.yml
index 38d95827..3634e304 100644
--- a/docker-compose-test.yml
+++ b/docker-compose-test.yml
@@ -1,26 +1,56 @@
-version: '3.2'
+version: '3.4'
+
+x-mysql: &mysql
+  environment:
+    MYSQL_ALLOW_EMPTY_PASSWORD: true
+  command: >
+    mysqld
+    --log-bin=mysql-bin.log
+    --server-id 1
+    --binlog-format=row
+    --gtid_mode=on
+    --enforce-gtid-consistency=on
+
+x-mariadb: &mariadb
+  environment:
+    MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 1
+  command: >
+    --server-id=1
+    --default-authentication-plugin=mysql_native_password
+    --log-bin=master-bin
+    --binlog-format=row
+
 services:
-  percona-5.7:
-    platform: linux/amd64
+  percona-5.7-ctl:
+    <<: *mysql
     image: percona:5.7
-    environment:
-      MYSQL_ALLOW_EMPTY_PASSWORD: true
-      MYSQL_DATABASE: pymysqlreplication_test
     ports:
-      - 3306:3306
-    command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates
-    restart: always
+      - "3307:3306"
     networks:
       - default
 
-  percona-5.7-ctl:
+  percona-5.7:
+    <<: *mysql
     image: percona:5.7
-    environment:
-      MYSQL_ALLOW_EMPTY_PASSWORD: true
-      MYSQL_DATABASE: pymysqlreplication_test
     ports:
-      - 3307:3307
-    command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates -P 3307
+      - "3306:3306"
+    networks:
+      - default
+
+  mariadb-10.6:
+    <<: *mariadb
+    image: mariadb:10.6
+    ports:
+      - "3308:3306"
+    volumes:
+      - type: bind
+        source: ./.mariadb
+        target: /opt/key_file
+      - type: bind
+        source: ./.mariadb/my.cnf
+        target: /etc/mysql/my.cnf
+    networks:
+      - default
 
   pymysqlreplication:
     build:
@@ -30,6 +60,9 @@ services:
         BASE_IMAGE: python:3.11-alpine
         MYSQL_5_7: percona-5.7
         MYSQL_5_7_CTL: percona-5.7-ctl
+        MYSQL_5_7_CTL_PORT: 3306
+        MARIADB_10_6: mariadb-10.6
+        MARIADB_10_6_PORT: 3306
 
     command:
       - /bin/sh
@@ -39,7 +72,7 @@ services:
         
         while :
         do
-          if mysql -h percona-5.7 --user=root --execute "USE pymysqlreplication_test;" 2>&1 >/dev/null && mysql -h percona-5.7-ctl --port=3307  --user=root --execute "USE pymysqlreplication_test;" 2>&1 >/dev/null; then
+          if mysql -h percona-5.7 --user=root --execute "SELECT version();" 2>&1 >/dev/null && mysql -h percona-5.7-ctl --user=root --execute "SELECT version();" 2>&1 >/dev/null; then
             break
           fi
           sleep 1
@@ -56,4 +89,5 @@ services:
       - percona-5.7-ctl
 
 networks:
-  default: {}
+  default:
+    driver: bridge
diff --git a/pymysqlreplication/tests/base.py b/pymysqlreplication/tests/base.py
index 009c3e29..6cb23094 100644
--- a/pymysqlreplication/tests/base.py
+++ b/pymysqlreplication/tests/base.py
@@ -125,10 +125,10 @@ class PyMySQLReplicationMariaDbTestCase(PyMySQLReplicationTestCase):
     def setUp(self):
         # default
         self.database = {
-            "host": "localhost",
+            "host": os.environ.get("MARIADB_10_6") or "localhost",
             "user": "root",
             "passwd": "",
-            "port": 3308,
+            "port": int(os.environ.get("MARIADB_10_6_PORT") or 3308),
             "use_unicode": True,
             "charset": "utf8",
             "db": "pymysqlreplication_test"
diff --git a/pymysqlreplication/tests/test_basic.py b/pymysqlreplication/tests/test_basic.py
index 32b237e0..ed6c62bd 100644
--- a/pymysqlreplication/tests/test_basic.py
+++ b/pymysqlreplication/tests/test_basic.py
@@ -771,9 +771,8 @@ def setUp(self):
         self.stream.close()
         ctl_db = copy.copy(self.database)
         ctl_db["db"] = None
-        ctl_db["port"] = 3307
-        if os.environ.get("MYSQL_5_7_CTL") is not None:
-            ctl_db["host"] = os.environ.get("MYSQL_5_7_CTL")
+        ctl_db["port"] = int(os.environ.get("MYSQL_5_7_CTL_PORT") or 3307)
+        ctl_db["host"] = os.environ.get("MYSQL_5_7_CTL") or "localhost"
         self.ctl_conn_control = pymysql.connect(**ctl_db)
         self.ctl_conn_control.cursor().execute("DROP DATABASE IF EXISTS pymysqlreplication_test")
         self.ctl_conn_control.cursor().execute("CREATE DATABASE pymysqlreplication_test")
diff --git a/test.Dockerfile b/test.Dockerfile
index 6aa2e34a..0272e00f 100644
--- a/test.Dockerfile
+++ b/test.Dockerfile
@@ -1,6 +1,7 @@
 ARG BASE_IMAGE=${BASE_IMAGE:-python:3.11-alpine}
 FROM ${BASE_IMAGE}
 
+COPY .mariadb .mariadb
 COPY pymysqlreplication pymysqlreplication
 COPY README.md README.md
 COPY setup.py setup.py
@@ -13,4 +14,13 @@ ARG MYSQL_5_7
 ENV MYSQL_5_7 ${MYSQL_5_7}
 
 ARG MYSQL_5_7_CTL
-ENV MYSQL_5_7_CTL ${MYSQL_5_7_CTL}
\ No newline at end of file
+ENV MYSQL_5_7_CTL ${MYSQL_5_7_CTL}
+
+ARG MYSQL_5_7_CTL_PORT
+ENV MYSQL_5_7_CTL_PORT ${MYSQL_5_7_CTL_PORT}
+
+ARG MARIADB_10_6
+ENV MARIADB_10_6 ${MARIADB_10_6}
+
+ARG MARIADB_10_6_PORT
+ENV MARIADB_10_6_PORT ${MARIADB_10_6_PORT}
\ No newline at end of file