Skip to content

Commit e31da67

Browse files
committed
Build/Test Tools: Check database readiness over TCP.
Ping 127.0.0.1 with --protocol=tcp in the local Docker environment and the installation and upgrade testing workflows. This prevents the temporary socket-only server used during database initialization from reporting healthy before TCP connections are available. Select the appropriate administration client for MariaDB versions in the CI healthchecks. Clarify why the standalone environment installation command retains its connection retry. Developed in: #13563 Props lucatume, adrianmoldovanwp. See #66117. git-svn-id: https://develop.svn.wordpress.org/trunk@63871 602fd350-edb4-49c9-b593-d223f7449a82
1 parent c754ebf commit e31da67

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

‎.github/workflows/install-testing.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ jobs:
113113
image: ${{ matrix.db-type }}:${{ matrix.db-version }}
114114
ports:
115115
- 3306
116+
# Ping over TCP, to wait for the TCP server rather than the Unix socket.
117+
# MariaDB 11.0 dropped the `mysqladmin` symlink, so pick the client the image ships.
116118
options: >-
117-
--health-cmd="mysqladmin ping"
119+
--health-cmd="${{ matrix.db-type == 'mariadb' && ! contains( fromJSON('["5.5", "10.0", "10.1", "10.2", "10.3"]'), matrix.db-version ) && 'mariadb-admin' || 'mysqladmin' }} ping -h 127.0.0.1 --protocol=tcp"
118120
--health-interval="30s"
119121
--health-timeout="10s"
120122
--health-retries="5"

‎.github/workflows/reusable-upgrade-testing.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ jobs:
7373
image: ${{ inputs.db-type }}:${{ inputs.db-version }}
7474
ports:
7575
- 3306
76+
# Ping over TCP, to wait for the TCP server rather than the Unix socket.
77+
# MariaDB 11.0 dropped the `mysqladmin` symlink, so pick the client the image ships.
7678
options: >-
77-
--health-cmd="mysqladmin ping"
79+
--health-cmd="${{ inputs.db-type == 'mariadb' && ! contains( fromJSON('["5.5", "10.0", "10.1", "10.2", "10.3"]'), inputs.db-version ) && 'mariadb-admin' || 'mysqladmin' }} ping -h 127.0.0.1 --protocol=tcp"
7880
--health-interval="30s"
7981
--health-timeout="10s"
8082
--health-retries="5"

‎docker-compose.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ services:
8080
- ./tools/local-env/mysql-init.sql:/docker-entrypoint-initdb.d/mysql-init.sql
8181
- mysql:/var/lib/mysql
8282

83+
# Ping over TCP: the client resolves the literal `localhost` to the Unix socket, which the
84+
# temporary `--skip-networking` server used to initialise a cold volume answers long before
85+
# the real server listens on port 3306.
8386
healthcheck:
8487
test: [
8588
'CMD-SHELL',
86-
'if [ "$LOCAL_DB_TYPE" = "mariadb" ]; then case "$LOCAL_DB_VERSION" in 5.5|10.0|10.1|10.2|10.3) mysqladmin ping -h localhost || exit $$?;; *) mariadb-admin ping -h localhost || exit $$?;; esac; else mysqladmin ping -h localhost || exit $$?; fi'
89+
'if [ "$LOCAL_DB_TYPE" = "mariadb" ]; then case "$LOCAL_DB_VERSION" in 5.5|10.0|10.1|10.2|10.3) mysqladmin ping -h 127.0.0.1 --protocol=tcp || exit $$?;; *) mariadb-admin ping -h 127.0.0.1 --protocol=tcp || exit $$?;; esac; else mysqladmin ping -h 127.0.0.1 --protocol=tcp || exit $$?; fi'
8790
]
8891
timeout: 5s
8992
interval: 5s

‎tools/local-env/scripts/install.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ local_env_utils.ensure_env_file();
1111

1212
dotenvExpand.expand( dotenv.config() );
1313

14-
// Create wp-config.php. This verifies the database connection, so retrying it doubles as the
15-
// readiness probe: the mysql healthcheck pings the container's own socket, which the temporary
16-
// server used to initialise a cold volume answers before the real server listens on TCP.
14+
// Create wp-config.php. This verifies the database connection, so retrying it keeps
15+
// `env:install` working on its own, without `env:start` having waited for the mysql
16+
// container to report healthy first.
1717
wp_cli_retry(
1818
`config create --dbname=wordpress_develop --dbuser=root --dbpass=password --dbhost=mysql --force --config-file="wp-config.php"`,
1919
{

0 commit comments

Comments
 (0)