Skip to content
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

Pool wait test #548

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/bin/ody-stop
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
kill $(pgrep odyssey) || (sleep 1 && kill -9 $(pgrep odyssey)) || true
pkill odyssey || (sleep 1 && kill -9 $(pgrep odyssey)) || true
1 change: 1 addition & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ ody-stop
/shell-test/console_role_test.sh
/shell-test/parse_pg_options_test.sh
/shell-test/override_pg_options_test.sh
/shell-test/pool_size_test.sh
ody-stop

ody-start
Expand Down
47 changes: 47 additions & 0 deletions docker/shell-test/pool_size.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
pid_file "/var/run/odyssey.pid"
daemonize yes

log_format "%p %t %l [%i %s] (%c) %m\n"

log_to_stdout yes

log_syslog no
log_syslog_ident "odyssey"
log_syslog_facility "daemon"

log_debug yes
log_config yes
log_session yes
log_query yes
log_stats yes


listen {
host "*"
port 6432
backlog 128
}


storage "postgres_server" {
type "remote"
host "localhost"
port 5432
}

database default {
user default {
authentication "none"
storage "postgres_server"
pool "transaction"
pool_size 10
pool_timeout 3000 # We expect 3 clients to do pg_sleep(1) each. Extra second to suppress falpping.
}
}

storage "local" {
type "local"
}


locks_dir "/tmp/odyssey"
23 changes: 23 additions & 0 deletions docker/shell-test/pool_size_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash -x
set -e
ody-stop

# We set pool size to 1 and check that 3 clients can do pg_sleep(1) at once.
# We expect them to wait serially on 1 backend.

/usr/bin/odyssey /shell-test/pool_size.conf


for _ in $(seq 1 300); do
psql -h 0.0.0.0 -p 6432 -c 'select pg_sleep(0.1)' -U user1 -d postgres &
done

for _ in $(seq 1 300); do
wait -n || {
code="$?"
([[ $code = "127" ]] && exit 0 || exit "$code")
break
}
done;

ody-stop
Loading