-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Run ProxySQL cluster inside single container + CI stability fixes #5528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6fcb8fd
8c67073
0590803
ce92a2a
359e6be
6769ea4
801a443
5a868d3
8705685
35a9bfb
cc9a041
e299de5
4837642
98b56ec
c84f411
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,28 @@ | ||
| #!/usr/bin/env bash | ||
| set -e | ||
| set -o pipefail | ||
| # | ||
| # Scheduler script: polls all ProxySQL cluster nodes to keep them active. | ||
| # Runs inside the ProxySQL container where all nodes are on 127.0.0.1. | ||
| # | ||
| # Port scheme: | ||
| # Primary: 6032 | ||
| # proxy-node1: 6042 | ||
| # proxy-node2: 6052 | ||
| # ... | ||
| # proxy-node9: 6122 | ||
|
|
||
| TABLES=(mysql_servers mysql_users mysql_query_rules mysql_query_rules_fast_routing global_variables proxysql_servers mysql_galera_hostgroups mysql_group_replication_hostgroups mysql_replication_hostgroups mysql_hostgroup_attributes) | ||
|
|
||
| ALL_TABLES=() | ||
|
|
||
| for i in ; do | ||
| ALL_TABLES+=() | ||
| ALL_TABLES+=("runtime_") | ||
| for i in ${!TABLES[@]}; do | ||
| ALL_TABLES+=(${TABLES[$i]}) | ||
| ALL_TABLES+=("runtime_"${TABLES[$i]}) | ||
| done | ||
|
|
||
| # The nodes in our containerized cluster | ||
| NODES="proxysql proxy-node1 proxy-node2 proxy-node3 proxy-node4 proxy-node5 proxy-node6 proxy-node7 proxy-node8 proxy-node9" | ||
| # Primary + up to 9 nodes, all on 127.0.0.1 with different ports | ||
| PORTS="6032 6042 6052 6062 6072 6082 6092 6102 6112 6122" | ||
|
|
||
| for host in ; do | ||
| # Use radmin/radmin for remote access between containers | ||
| for i in ; do | ||
| echo "SELECT COUNT(*) FROM ;" | ||
| done | mysql -u radmin -pradmin -h -P 6032 > /dev/null & | ||
| for port in ${PORTS}; do | ||
| for i in ${!ALL_TABLES[@]}; do | ||
| echo "SELECT COUNT(*) FROM ${ALL_TABLES[$i]};" | ||
| done | mysql -u admin -padmin -h 127.0.0.1 -P ${port} > /dev/null 2>&1 & | ||
| done | ||
|
Comment on lines
+24
to
28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The inner loop generating SQL queries can be made more efficient and readable by using |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,10 +59,17 @@ export TAP_DEPS="${WORKSPACE}/test/tap/tap" | |
| export TEST_DEPS_PATH="${WORKSPACE}/test-scripts/deps" | ||
| export TEST_DEPS="${TEST_DEPS_PATH}" | ||
|
|
||
| # Cluster Nodes | ||
| # Cluster Nodes — all run inside the ProxySQL container on different ports | ||
| # Port scheme: proxy-node1=6042, proxy-node2=6052, ..., proxy-node9=6122 | ||
| # From the test-runner container, reach them via the proxysql hostname | ||
| NUM_CLUSTER_NODES=${PROXYSQL_CLUSTER_NODES:-9} | ||
| if [[ "${SKIP_CLUSTER_START}" == "1" ]] || [[ "${SKIP_CLUSTER_START}" == "true" ]]; then | ||
| NUM_CLUSTER_NODES=0 | ||
| fi | ||
| CLUSTER_NODES="" | ||
| for i in $(seq 1 9); do | ||
| CLUSTER_NODES="${CLUSTER_NODES}proxy-node${i}:6032," | ||
| for i in $(seq 1 ${NUM_CLUSTER_NODES}); do | ||
| PORT=$((6032 + i * 10)) | ||
| CLUSTER_NODES="${CLUSTER_NODES}proxysql:${PORT}," | ||
| done | ||
|
Comment on lines
+62
to
73
|
||
| export TAP_CLUSTER_NODES=${CLUSTER_NODES%,} | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop can be written more idiomatically using
for item in "${array[@]}"syntax, which is generally more readable and less error-prone than iterating over indices.