Skip to content

Commit db18510

Browse files
authored
Merge branch 'develop' into sam/pgroonga-update
2 parents dadb895 + 5ccf795 commit db18510

File tree

4 files changed

+80
-19
lines changed

4 files changed

+80
-19
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Set PostgreSQL versions
2727
id: set-versions
2828
run: |
29-
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[] | select(. != "orioledb-17")' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]')
29+
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c "split(\"\n\")[:-1]")
3030
echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT
3131
build:
3232
needs: prepare

ansible/tasks/setup-system.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,17 @@
183183
ansible.posix.sysctl:
184184
name: 'net.ipv4.ip_local_port_range'
185185
value: '1025 65000'
186+
187+
#Set Sysctl params specific to keepalives
188+
- name: Set net.ipv4.tcp_keepalive_time=1800
189+
ansible.builtin.sysctl:
190+
name: net.ipv4.tcp_keepalive_time
191+
value: 1800
192+
state: present
193+
when: debpkg_mode or nixpkg_mode
194+
- name: Set net.ipv4.tcp_keepalive_intvl=60
195+
ansible.builtin.sysctl:
196+
name: net.ipv4.tcp_keepalive_intvl
197+
value: 60
198+
state: present
199+
when: debpkg_mode or nixpkg_mode

ansible/vars.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ postgres_major:
88

99
# Full version strings for each major version
1010
postgres_release:
11-
postgresorioledb-17: "17.0.1.022-orioledb-pgroonga-1"
12-
postgres15: "15.8.1.032-pgroonga-1"
11+
postgresorioledb-17: "17.0.1.022-orioledb"
12+
postgres15: "15.8.1.032"
1313

1414
# Non Postgres Extensions
1515
pgbouncer_release: "1.19.0"

nix/tools/dbmate-tool.sh.in

Lines changed: 63 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,31 @@ STAT_EXTENSION_SQL=@STAT_EXTENSION_SQL@
1919
cleanup() {
2020
echo "Cleaning up..."
2121

22-
# Kill overmind processes first
22+
# Kill postgres processes first
23+
if pgrep -f "postgres" >/dev/null; then
24+
pkill -TERM postgres || true
25+
sleep 2
26+
fi
27+
28+
# Then kill overmind
2329
if [ -S "./.overmind.sock" ]; then
2430
overmind kill || true
2531
sleep 2
2632
fi
2733

28-
# Kill any remaining postgres processes
29-
echo "Killing any remaining postgres processes..."
30-
pkill -9 postgres || true
31-
pkill -9 -f "tmux.*overmind.*postgresql" || true
32-
33-
# Extra cleanup for tmux sessions
34+
# Kill tmux sessions explicitly
35+
pkill -f "tmux.*overmind.*postgresql" || true
3436
tmux ls 2>/dev/null | grep 'overmind' | cut -d: -f1 | xargs -I{} tmux kill-session -t {} || true
37+
38+
# Force kill any stragglers
39+
pkill -9 -f "(postgres|tmux.*overmind.*postgresql)" || true
3540

36-
# Remove socket and Procfile
3741
rm -f .overmind.sock Procfile
38-
39-
# Verify cleanup
40-
remaining=$(ps aux | grep -E "(postgres|overmind|tmux.*postgresql)" | grep -v grep || true)
41-
if [ ! -z "$remaining" ]; then
42-
echo "Warning: Some processes might still be running:"
43-
echo "$remaining"
42+
43+
# Final verification
44+
if ps aux | grep -E "(postgres|overmind|tmux.*postgresql)" | grep -v grep >/dev/null; then
45+
ps aux | grep -E "(postgres|overmind|tmux.*postgresql)" | grep -v grep
46+
return 1
4447
fi
4548
}
4649

@@ -143,6 +146,24 @@ wait_for_postgres() {
143146
return 1
144147
}
145148

149+
check_orioledb_ready() {
150+
local max_attempts=30
151+
local attempt=1
152+
153+
while [ $attempt -le $max_attempts ]; do
154+
if "${PSQLBIN}/psql" -v ON_ERROR_STOP=1 -U "$PGSQL_SUPERUSER" -p "$PORTNO" -h localhost -d postgres -c "SELECT * FROM pg_am WHERE amname = 'orioledb'" | grep -q orioledb; then
155+
echo "Orioledb extension is ready!"
156+
return 0
157+
fi
158+
echo "Waiting for orioledb to be ready (attempt $attempt/$max_attempts)..."
159+
sleep 2
160+
attempt=$((attempt + 1))
161+
done
162+
163+
echo "Orioledb failed to initialize after $max_attempts attempts"
164+
return 1
165+
}
166+
146167
trim_schema() {
147168
case "$CURRENT_SYSTEM" in
148169
"x86_64-darwin"|"aarch64-darwin")
@@ -165,7 +186,7 @@ EOF
165186
while [ $count -lt $max_wait ]; do
166187
if [ -S "./.overmind.sock" ]; then
167188
# Found the socket, give it a moment to be ready
168-
sleep 2
189+
sleep 5
169190
echo "Socket file found and ready"
170191
break
171192
fi
@@ -174,6 +195,25 @@ EOF
174195
count=$((count + 1))
175196
done
176197
}
198+
perform_dump() {
199+
local max_attempts=3
200+
local attempt=1
201+
202+
while [ $attempt -le $max_attempts ]; do
203+
echo "Attempting dbmate dump (attempt $attempt/$max_attempts)"
204+
205+
if dbmate dump; then
206+
return 0
207+
fi
208+
209+
echo "Dump attempt $attempt failed, waiting before retry..."
210+
sleep 5
211+
attempt=$((attempt + 1))
212+
done
213+
214+
echo "All dump attempts failed"
215+
return 1
216+
}
177217
migrate_version() {
178218
echo "PSQL_VERSION: $PSQL_VERSION"
179219
overmind kill || true
@@ -193,6 +233,13 @@ migrate_version() {
193233
echo "Failed to connect to PostgreSQL server"
194234
exit 1
195235
fi
236+
237+
if [ "$PSQL_VERSION" = "orioledb-17" ]; then
238+
if ! check_orioledb_ready; then
239+
echo "Failed to initialize orioledb extension"
240+
exit 1
241+
fi
242+
fi
196243

197244
echo "PostgreSQL server is ready"
198245

@@ -233,7 +280,7 @@ EOSQL
233280
fi
234281

235282
echo "Running dbmate dump with $PSQLBIN"
236-
dbmate dump
283+
perform_dump
237284

238285
echo "CURRENT_SYSTEM: $CURRENT_SYSTEM"
239286
if [ -f "./db/schema.sql" ]; then

0 commit comments

Comments
 (0)