Skip to content

Commit 57db869

Browse files
fix(ci): Fix race condition with InnoDB and postgres password
1 parent 6c8b57d commit 57db869

File tree

3 files changed

+53
-8
lines changed

3 files changed

+53
-8
lines changed

.github/workflows/build_and_test.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ jobs:
8787
MARIADB_DATABASE: vendure
8888
MARIADB_USER: vendure
8989
MARIADB_PASSWORD: password
90+
# Ensure InnoDB is used for locking support
91+
MARIADB_MYSQL_LOCALHOST_USER: 1
92+
MARIADB_INITDB_SKIP_TZINFO: 1
9093
ports:
9194
- 3306
92-
options: --health-cmd="mariadb-admin ping -h localhost -u vendure -ppassword" --health-interval=10s --health-timeout=5s --health-retries=3
95+
options: --health-cmd="mariadb-admin ping -h localhost -u vendure -ppassword" --health-interval=10s --health-timeout=5s --health-retries=3 --command="mysqld --innodb_file_per_table=1 --default-storage-engine=InnoDB --innodb_flush_log_at_trx_commit=2 --innodb_log_buffer_size=32M"
9396
mysql:
9497
image: vendure/mysql-8-native-auth:latest
9598
env:
@@ -146,39 +149,44 @@ jobs:
146149
- name: Build
147150
run: npx lerna run ci
148151
- name: Wait for services to be ready
152+
env:
153+
E2E_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
154+
E2E_MARIADB_PORT: ${{ job.services.mariadb.ports['3306'] }}
155+
E2E_POSTGRES_PORT: ${{ job.services.postgres.ports['5432'] }}
156+
E2E_ELASTIC_PORT: ${{ job.services.elastic.ports['9200'] }}
157+
E2E_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
158+
DB: ${{ matrix.db }}
149159
run: |
150160
echo "Waiting for required services..."
151161
# Wait for redis
152-
for i in {1..60}; do
162+
for i in {1..30}; do
153163
if nc -z localhost $E2E_REDIS_PORT; then break; fi
154164
sleep 1
155165
done
156166
157167
# Wait for DB ports depending on matrix value
158168
if [ "$DB" = "postgres" ]; then
159-
for i in {1..60}; do
169+
for i in {1..30}; do
160170
if nc -z localhost $E2E_POSTGRES_PORT; then break; fi
161171
sleep 1
162172
done
163173
elif [ "$DB" = "mariadb" ]; then
164-
for i in {1..60}; do
174+
for i in {1..30}; do
165175
if nc -z localhost $E2E_MARIADB_PORT; then break; fi
166176
sleep 1
167177
done
168178
elif [ "$DB" = "mysql" ]; then
169-
for i in {1..60}; do
179+
for i in {1..30}; do
170180
if nc -z localhost $E2E_MYSQL_PORT; then break; fi
171181
sleep 1
172182
done
173183
fi
174184
175185
# Wait for Elasticsearch
176-
for i in {1..60}; do
186+
for i in {1..30}; do
177187
if curl --silent --fail http://localhost:$E2E_ELASTIC_PORT/_cluster/health >/dev/null 2>&1; then break; fi
178188
sleep 1
179189
done
180-
181-
echo "Services appear reachable."
182190
- name: e2e tests
183191
env:
184192
E2E_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
MARIADB_USER: vendure
1212
MARIADB_PASSWORD: password
1313
MARIADB_ROOT_PASSWORD: password
14+
command: ["mysqld", "--innodb_file_per_table=1", "--default-storage-engine=InnoDB"]
1415
volumes:
1516
- 'mariadb_data:/var/lib/mysql'
1617
ports:

e2e-common/test-config.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ function getDbConfig(): DataSourceOptions {
9797
port: process.env.CI ? +(process.env.E2E_POSTGRES_PORT || 5432) : 5432,
9898
username: 'vendure',
9999
password: 'password',
100+
// Connection timeouts to prevent aborted connections
101+
connectTimeout: 60000,
102+
// Keep connections alive
103+
keepConnectionAlive: true,
104+
extra: {
105+
// Connection pool settings
106+
max: 10,
107+
idleTimeoutMillis: 30000,
108+
connectionTimeoutMillis: 60000,
109+
},
100110
};
101111
case 'mariadb':
102112
return {
@@ -106,6 +116,19 @@ function getDbConfig(): DataSourceOptions {
106116
port: process.env.CI ? +(process.env.E2E_MARIADB_PORT || 3306) : 3306,
107117
username: 'vendure',
108118
password: 'password',
119+
extra: {
120+
// Ensure tables use InnoDB for locking support
121+
initSql: "SET default_storage_engine=InnoDB;",
122+
// Connection pool settings
123+
connectionLimit: 10,
124+
waitForConnections: true,
125+
queueLimit: 0,
126+
},
127+
// Connection timeouts to prevent aborted connections
128+
connectTimeout: 60000,
129+
acquireTimeout: 60000,
130+
// Keep connections alive
131+
keepConnectionAlive: true,
109132
};
110133
case 'mysql':
111134
return {
@@ -115,6 +138,19 @@ function getDbConfig(): DataSourceOptions {
115138
port: process.env.CI ? +(process.env.E2E_MYSQL_PORT || 3306) : 3306,
116139
username: 'vendure',
117140
password: 'password',
141+
extra: {
142+
// Ensure tables use InnoDB for locking support
143+
initSql: "SET default_storage_engine=InnoDB;",
144+
// Connection pool settings
145+
connectionLimit: 10,
146+
waitForConnections: true,
147+
queueLimit: 0,
148+
},
149+
// Connection timeouts to prevent aborted connections
150+
connectTimeout: 60000,
151+
acquireTimeout: 60000,
152+
// Keep connections alive
153+
keepConnectionAlive: true,
118154
};
119155
case 'sqljs':
120156
default:

0 commit comments

Comments
 (0)