Fix ProxySQL user registration collisions in multi-infra environments (ref #5439)

- Replace REPLACE INTO with INSERT OR IGNORE INTO for mysql_users.
- Prevents subsequent infrastructures from overwriting shared users like testuser/root.
- Ensures the first infra in the loading order defines the primary default_hostgroup.
pull/5444/head
Rene Cannao 2 months ago
parent c9d78c6e45
commit 785fbef3e4

1
.gitignore vendored

@ -83,6 +83,7 @@ src/*log*
#test artifacts
ci_infra_logs/
test/tap/tap/*.mri
test/tap/tests/test_cluster_sync_config/test_cluster_sync_withmonitor/cluster_sync_node_stderr.txt
proxysql-2.0.0/
docker/images/proxysql/rhel-compliant/rpmmacros

@ -18,19 +18,19 @@ LOAD MYSQL SERVERS TO RUNTIME;
SAVE MYSQL SERVERS TO DISK;
DELETE FROM mysql_users WHERE comment LIKE '%${INFRA}';
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('root','${ROOT_PASSWORD}',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('user','user',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('testuser','testuser',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest1','sbtest1',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest2','sbtest2',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest3','sbtest3',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest4','sbtest4',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('ssluser','ssluser',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('${INFRA}','${INFRA}',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('root','${ROOT_PASSWORD}',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('user','user',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('testuser','testuser',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest1','sbtest1',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest2','sbtest2',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest3','sbtest3',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest4','sbtest4',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('ssluser','ssluser',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('${INFRA}','${INFRA}',1,${WHG},'${INFRA}');
-- MariaDB specific users for the Fast Forward test
REPLACE INTO mysql_users (username,password,active,default_hostgroup,fast_forward,comment) values ('mariadbuser','mariadbuser',1,${WHG},0,'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,fast_forward,comment) values ('mariadbuserff','mariadbuserff',1,${WHG},1,'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,fast_forward,comment) values ('mariadbuser','mariadbuser',1,${WHG},0,'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,fast_forward,comment) values ('mariadbuserff','mariadbuserff',1,${WHG},1,'${INFRA}');
LOAD MYSQL USERS TO RUNTIME;
SAVE MYSQL USERS TO DISK;

@ -14,16 +14,16 @@ DELETE FROM mysql_users WHERE username='root';
DELETE FROM mysql_users WHERE username='testuser';
-- Register root user (fast_forward=0 by default)
REPLACE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
INSERT OR IGNORE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
VALUES ('root', '${ROOT_PASSWORD}', 1, ${WHG}, 0, 1, 1, 'dynamic-root-user');
-- Register testuser (fast_forward=0 by default)
REPLACE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
INSERT OR IGNORE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
VALUES ('testuser', 'testuser', 1, ${WHG}, 0, 1, 1, 'universal-testuser');
-- Ensure cluster specific user is also correctly set
DELETE FROM mysql_users WHERE username='${INFRA}';
REPLACE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
INSERT OR IGNORE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
VALUES ('${INFRA}', '${INFRA}', 1, ${WHG}, 0, 1, 1, '${INFRA}');
-- Synchronize monitor credentials

@ -3,7 +3,7 @@
"ListenAddress": ":3000",
"MySQLTopologySSLSkipVerify": true,
"MySQLTopologyUser": "root",
"MySQLTopologyPassword": "05e1229f3d",
"MySQLTopologyPassword": "177f004d88",
"BackendDB": "sqlite",
"SQLite3DataFile": "/var/lib/orchestrator/orchestrator.db",
"RaftEnabled": true,

@ -3,7 +3,7 @@
"ListenAddress": ":3000",
"MySQLTopologySSLSkipVerify": true,
"MySQLTopologyUser": "root",
"MySQLTopologyPassword": "05e1229f3d",
"MySQLTopologyPassword": "177f004d88",
"BackendDB": "sqlite",
"SQLite3DataFile": "/var/lib/orchestrator/orchestrator.db",
"RaftEnabled": true,

@ -3,7 +3,7 @@
"ListenAddress": ":3000",
"MySQLTopologySSLSkipVerify": true,
"MySQLTopologyUser": "root",
"MySQLTopologyPassword": "05e1229f3d",
"MySQLTopologyPassword": "177f004d88",
"BackendDB": "sqlite",
"SQLite3DataFile": "/var/lib/orchestrator/orchestrator.db",
"RaftEnabled": true,

@ -24,16 +24,16 @@ LOAD MYSQL SERVERS TO RUNTIME;
SAVE MYSQL SERVERS TO DISK;
DELETE FROM mysql_users WHERE comment LIKE '%${INFRA}';
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('root','root',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('root','root',1,${WHG},'${INFRA}');
UPDATE mysql_users SET default_hostgroup=${WHG},comment='${INFRA}' WHERE username='root';
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('user','user',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('testuser','testuser',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest1','sbtest1',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest2','sbtest2',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest3','sbtest3',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest4','sbtest4',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('ssluser','ssluser',1,${WHG},'${INFRA}');
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('${INFRA}','${INFRA}',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('user','user',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('testuser','testuser',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest1','sbtest1',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest2','sbtest2',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest3','sbtest3',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('sbtest4','sbtest4',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('ssluser','ssluser',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('${INFRA}','${INFRA}',1,${WHG},'${INFRA}');
LOAD MYSQL USERS TO RUNTIME;
SAVE MYSQL USERS TO DISK;

@ -14,16 +14,16 @@ DELETE FROM mysql_users WHERE username='root';
DELETE FROM mysql_users WHERE username='testuser';
-- Register root user (fast_forward=0 by default)
REPLACE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
INSERT OR IGNORE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
VALUES ('root', '${ROOT_PASSWORD}', 1, ${WHG}, 0, 1, 1, 'dynamic-root-user');
-- Register testuser (fast_forward=0 by default)
REPLACE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
INSERT OR IGNORE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
VALUES ('testuser', 'testuser', 1, ${WHG}, 0, 1, 1, 'universal-testuser');
-- Ensure cluster specific user is also correctly set
DELETE FROM mysql_users WHERE username='${INFRA}';
REPLACE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
INSERT OR IGNORE INTO mysql_users (username, password, active, default_hostgroup, fast_forward, backend, frontend, comment)
VALUES ('${INFRA}', '${INFRA}', 1, ${WHG}, 0, 1, 1, '${INFRA}');
-- Synchronize monitor credentials

@ -25,7 +25,7 @@ LOAD MYSQL SERVERS TO RUNTIME;
SAVE MYSQL SERVERS TO DISK;
DELETE FROM mysql_users WHERE comment LIKE '%${INFRA}';
REPLACE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('${INFRA}','${INFRA}',1,${WHG},'${INFRA}');
INSERT OR IGNORE INTO mysql_users (username,password,active,default_hostgroup,comment) values ('${INFRA}','${INFRA}',1,${WHG},'${INFRA}');
LOAD MYSQL USERS TO RUNTIME;
SAVE MYSQL USERS TO DISK;

@ -211,3 +211,45 @@ WARNING: this is a DEBUG release and can be slow or perform poorly. Do not use i
2026-03-08 23:56:51 ProxySQL_Cluster.cpp:244:ProxySQL_Cluster_Monitor_thread(): [WARNING] Cluster: unable to connect to peer proxysql:6032 . Error: ProxySQL Error: Access denied for user 'cluster1'@'172.21.0.14' (using password: YES)
2026-03-08 23:56:53 ProxySQL_Cluster.cpp:244:ProxySQL_Cluster_Monitor_thread(): [WARNING] Cluster: unable to connect to peer proxysql:6032 . Error: ProxySQL Error: Access denied for user 'cluster1'@'172.21.0.14' (using password: YES)
2026-03-08 23:56:55 ProxySQL_Cluster.cpp:244:ProxySQL_Cluster_Monitor_thread(): [WARNING] Cluster: unable to connect to peer proxysql:6032 . Error: ProxySQL Error: Access denied for user 'cluster1'@'172.21.0.14' (using password: YES)
2026-03-08 23:56:57 ProxySQL_Cluster.cpp:244:ProxySQL_Cluster_Monitor_thread(): [WARNING] Cluster: unable to connect to peer proxysql:6032 . Error: ProxySQL Error: Access denied for user 'cluster1'@'172.21.0.14' (using password: YES)
2026-03-08 23:56:59 ProxySQL_Cluster.cpp:244:ProxySQL_Cluster_Monitor_thread(): [WARNING] Cluster: unable to connect to peer proxysql:6032 . Error: ProxySQL Error: Access denied for user 'cluster1'@'172.21.0.14' (using password: YES)
2026-03-08 23:57:01 ProxySQL_Cluster.cpp:244:ProxySQL_Cluster_Monitor_thread(): [WARNING] Cluster: unable to connect to peer proxysql:6032 . Error: ProxySQL Error: Access denied for user 'cluster1'@'172.21.0.14' (using password: YES)
2026-03-08 23:57:03 ProxySQL_Cluster.cpp:244:ProxySQL_Cluster_Monitor_thread(): [WARNING] Cluster: unable to connect to peer proxysql:6032 . Error: ProxySQL Error: Access denied for user 'cluster1'@'172.21.0.14' (using password: YES)
2026-03-08 23:57:06 ProxySQL_Cluster.cpp:244:ProxySQL_Cluster_Monitor_thread(): [WARNING] Cluster: unable to connect to peer proxysql:6032 . Error: ProxySQL Error: Access denied for user 'cluster1'@'172.21.0.14' (using password: YES)
2026-03-08 23:57:08 ProxySQL_Cluster.cpp:244:ProxySQL_Cluster_Monitor_thread(): [WARNING] Cluster: unable to connect to peer proxysql:6032 . Error: ProxySQL Error: Access denied for user 'cluster1'@'172.21.0.14' (using password: YES)
2026-03-08 23:57:10 ProxySQL_Cluster.cpp:244:ProxySQL_Cluster_Monitor_thread(): [WARNING] Cluster: unable to connect to peer proxysql:6032 . Error: ProxySQL Error: Access denied for user 'cluster1'@'172.21.0.14' (using password: YES)
2026-03-08 23:57:10 ProxySQL_GloVars.cpp:32:term_handler(): [WARNING] Received TERM signal: shutdown in progress...
2026-03-08 23:57:10 main.cpp:3122:main(): [INFO] Starting shutdown...
GloMTH joined in 0.003465 secs.
GloPTH joined in 0.001297 secs.
2026-03-08 23:57:10 PgSQL_Monitor.cpp:2254:PgSQL_monitor_scheduler_thread(): [INFO] Exiting PgSQL_Monitor scheduling thread
2026-03-08 23:57:10 PgSQL_Monitor.cpp:1763:worker_thread(): [INFO] Received exit signal. Stopping worker thread=137464819742400
2026-03-08 23:57:10 PgSQL_Monitor.cpp:1763:worker_thread(): [INFO] Received exit signal. Stopping worker thread=137464817641152
GloMyMon joined in 0.176468 secs.
GloPgMon joined in 0.370958 secs.
GloMyQC and GloPgQC joined in 6.5e-05 secs.
All threads joined in 0.552288 secs.
GloMyMon shutdown in 5.3e-05 secs.
GloPgMon shutdown in 2e-05 secs.
GloMyQC shutdown in 1.8e-05 secs.
GloPgQC shutdown in 1.2e-05 secs.
GloMyQPro shutdown in 1.6e-05 secs.
GloPgQPro shutdown in 1e-05 secs.
GloMyAuth shutdown in 1.6e-05 secs.
GloPgAuth shutdown in 5e-06 secs.
GloMTH shutdown in 8.5e-05 secs.
GloPTH shutdown in 3.6e-05 secs.
GloMCPH shutdown in 2e-06 secs.
2026-03-08 23:57:11 GenAI_Thread.cpp:330:shutdown(): [INFO] Shutting down GenAI module
GloGATH shutdown in 0.000287 secs.
2026-03-08 23:57:11 AI_Features_Manager.cpp:483:shutdown(): [INFO] AI: Shutting down AI Features Manager
2026-03-08 23:57:11 AI_Features_Manager.cpp:489:shutdown(): [INFO] AI: AI Features Manager shutdown complete
GloAI shutdown in 1.9e-05 secs.
GloMyLogger shutdown in 1.5e-05 secs.
GloPgSQL_Logger shutdown in 6e-06 secs.
GloAdmin shutdown in 0.001051 secs.
GloMyHGM shutdown in 0.000145 secs.
GloPgHGM shutdown in 6.6e-05 secs.
Main init phase4 shutdown completed in 0.554228 secs.
2026-03-08 23:57:11 main.cpp:3129:main(): [INFO] Shutdown completed!
2026-03-08 23:57:11 main.cpp:3142:main(): [INFO] Exiting...

Loading…
Cancel
Save