ProxySQL Admin Tool should handle parallel calls more robust

Percona XtraDB Operator calls proxysql-admin –syncusers –add-query-rules every 5 seconds.

proxysql-admin begins with calling

proxysql_exec "$LINENO" "SAVE MYSQL SERVERS FROM RUNTIME"
proxysql_exec "$LINENO" "SAVE MYSQL QUERY RULES FROM RUNTIME"
proxysql_exec "$LINENO" "SAVE MYSQL USERS FROM RUNTIME"
proxysql_exec "$LINENO" "SAVE MYSQL VARIABLES FROM RUNTIME"

This leads to reverting configuration changes every 5 seconds. Why is it necessary? ProxySQL Admin should call LOAD MYSQL SERVERS TO RUNTIME immediately after any mysql_servers change and RUNTIME should not differ from MEMORY table.

        # Update the write_node to have a higher priority
        proxysql_exec "$LINENO" \
          "UPDATE mysql_servers
            SET weight = 1000000
            WHERE
              hostname = '$writer_ws_ip' AND
              port = $writer_ws_port AND
              hostgroup_id = $WRITER_HOSTGROUP_ID;"
        check_cmd $? "$LINENO" "Failed to update the writer-node" \
                             "\n-- Please check the ProxySQL connection parameters and status."

This part seems to be unnecessary, because max_writers=1 is set in mysql_galera_hostgroups too. And it has a negative side-effect, that weight=1000000 is cloned by ProxySQL when it is copying nodes from writer to reader hostgroup.

When I remove the UPDATE mentioned above, the node config will be correct:

+--------------+-------------------------------------------------+---------+--------+
| hostgroup_id | hostname                                        | status  | weight |
+--------------+-------------------------------------------------+---------+--------+
| 10           | mysql-pxc-0.mysql-pxc.kiskele.svc.cluster.local | ONLINE  | 1000   |
| 10           | mysql-pxc-1.mysql-pxc.kiskele.svc.cluster.local | ONLINE  | 1000   |
| 10           | mysql-pxc-2.mysql-pxc.kiskele.svc.cluster.local | ONLINE  | 1000   |
| 11           | mysql-pxc-0.mysql-pxc.kiskele.svc.cluster.local | SHUNNED | 1000   |
| 11           | mysql-pxc-1.mysql-pxc.kiskele.svc.cluster.local | SHUNNED | 1000   |
| 11           | mysql-pxc-2.mysql-pxc.kiskele.svc.cluster.local | ONLINE  | 1000   |
| 12           | mysql-pxc-0.mysql-pxc.kiskele.svc.cluster.local | ONLINE  | 1000   |
| 12           | mysql-pxc-1.mysql-pxc.kiskele.svc.cluster.local | ONLINE  | 1000   |
+--------------+-------------------------------------------------+---------+--------+