From b45368c901c1dcc880548567c597588306199ab1 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 10 May 2024 19:27:40 +0000 Subject: [PATCH 1/8] Enable use of pg_stat_statement extension in local docker-compose and CI pipeline --- .github/workflows/maven.yml | 47 ++++++++++++++++------- .gitignore | 4 +- docker/postgres-latest/docker-compose.yml | 8 +++- docker/postgres-latest/up.sh | 18 +++++++++ 4 files changed, 61 insertions(+), 16 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index b0f386977..867d63ec2 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -86,6 +86,21 @@ jobs: name: benchbase-${{matrix.profile}} path: target/benchbase-${{matrix.profile}}.tgz + # Needed for running a customized service containers using docker/*/up.sh scripts. + # See postgres example below. + # https://github.com/actions/runner/issues/2139 + - name: Package docker-compose configs + if: ${{ matrix.profile == 'postgres' }} + run: | + tar czvpf docker-compose-${{matrix.profile}}.tar.gz docker/${{matrix.profile}}-latest + + - name: Upload docker-compose configs + if: ${{ matrix.profile == 'postgres' }} + uses: actions/upload-artifact@v4 + with: + name: docker-compose-${{matrix.profile}} + path: docker-compose-${{matrix.profile}}.tar.gz + ## ---------------------------------------------------------------------------------- ## SQLITE ## ---------------------------------------------------------------------------------- @@ -406,21 +421,25 @@ jobs: fail-fast: false matrix: benchmark: [ 'auctionmark', 'epinions', 'hyadapt', 'noop', 'otmetrics', 'resourcestresser', 'seats', 'sibench', 'smallbank', 'tatp', 'templated', 'tpcc', 'tpcc-with-reconnects', 'tpch', 'twitter', 'voter', 'wikipedia', 'ycsb' ] - services: - postgres: # https://hub.docker.com/_/postgres - image: postgres:latest - env: - POSTGRES_DB: benchbase - POSTGRES_USER: admin - POSTGRES_PASSWORD: password - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 steps: + # Note: we download just the docker-compose scripts/configs rather than the + # whole source code repo for better testing. + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: docker-compose-postgres + + - name: Extract docker-compose artifacts + run: | + tar xvzf docker-compose-postgres.tar.gz + + # Use docker-compose to start the postgres service so we can modify the + # command line args to include extensions. + # https://github.com/actions/runner/issues/2139 + - name: Start custom postgres service + run: | + ./docker/postgres-latest/up.sh + - name: Download artifact uses: actions/download-artifact@v4 with: diff --git a/.gitignore b/.gitignore index da45607e2..756c1fb4f 100644 --- a/.gitignore +++ b/.gitignore @@ -55,4 +55,6 @@ build/ # vim swap files .*.swp -.env \ No newline at end of file +.env + +docker-compose-*.tar.gz diff --git a/docker/postgres-latest/docker-compose.yml b/docker/postgres-latest/docker-compose.yml index 982a2b517..56294cc34 100644 --- a/docker/postgres-latest/docker-compose.yml +++ b/docker/postgres-latest/docker-compose.yml @@ -6,13 +6,19 @@ services: container_name: postgres hostname: postgres image: postgres:alpine - command: postgres -N 500 + command: postgres -N 500 -c shared_preload_libraries=pg_stat_statements environment: POSTGRES_USER: admin POSTGRES_PASSWORD: password POSTGRES_DB: benchbase ports: - "5432:5432" + healthcheck: + test: pg_isready + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s postgres-ui: container_name: postgres-ui diff --git a/docker/postgres-latest/up.sh b/docker/postgres-latest/up.sh index d05249baf..57aa331f4 100755 --- a/docker/postgres-latest/up.sh +++ b/docker/postgres-latest/up.sh @@ -5,3 +5,21 @@ scriptdir=$(dirname "$(readlink -f "$0")") cd "$scriptdir/" docker compose up -d + +# Wait until ready +for i in {1..30}; do + if docker exec postgres pg_isready; then + break + else + sleep 1 + fi +done + +function run_psql_in_docker() { + set -x + docker exec --env PGPASSWORD=password postgres psql -h localhost -U admin benchbase --csv -c "$@" + set +x +} + +run_psql_in_docker "CREATE EXTENSION pg_stat_statements" +run_psql_in_docker "SELECT COUNT(*) FROM pg_stat_statements" | egrep '^[1-9][0-9]*$' \ No newline at end of file From 88af8e65bcc3489c953f36aaf7cb9c3151008614 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 10 May 2024 19:27:40 +0000 Subject: [PATCH 2/8] Enable use of pg_stat_statement extension in local docker-compose and CI pipeline --- .github/workflows/maven.yml | 47 ++++++++++++++++------- .gitignore | 4 +- docker/postgres-latest/docker-compose.yml | 8 +++- docker/postgres-latest/up.sh | 18 +++++++++ 4 files changed, 61 insertions(+), 16 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 345c52b86..0256d2b96 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -86,6 +86,21 @@ jobs: name: benchbase-${{matrix.profile}} path: target/benchbase-${{matrix.profile}}.tgz + # Needed for running a customized service containers using docker/*/up.sh scripts. + # See postgres example below. + # https://github.com/actions/runner/issues/2139 + - name: Package docker-compose configs + if: ${{ matrix.profile == 'postgres' }} + run: | + tar czvpf docker-compose-${{matrix.profile}}.tar.gz docker/${{matrix.profile}}-latest + + - name: Upload docker-compose configs + if: ${{ matrix.profile == 'postgres' }} + uses: actions/upload-artifact@v4 + with: + name: docker-compose-${{matrix.profile}} + path: docker-compose-${{matrix.profile}}.tar.gz + ## ---------------------------------------------------------------------------------- ## SQLITE ## ---------------------------------------------------------------------------------- @@ -406,21 +421,25 @@ jobs: fail-fast: false matrix: benchmark: [ 'auctionmark', 'epinions', 'hyadapt', 'noop', 'otmetrics', 'resourcestresser', 'seats', 'sibench', 'smallbank', 'tatp', 'templated', 'tpcc', 'tpcc-with-reconnects', 'tpch', 'twitter', 'voter', 'wikipedia', 'ycsb' ] - services: - postgres: # https://hub.docker.com/_/postgres - image: postgres:latest - env: - POSTGRES_DB: benchbase - POSTGRES_USER: admin - POSTGRES_PASSWORD: password - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 steps: + # Note: we download just the docker-compose scripts/configs rather than the + # whole source code repo for better testing. + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: docker-compose-postgres + + - name: Extract docker-compose artifacts + run: | + tar xvzf docker-compose-postgres.tar.gz + + # Use docker-compose to start the postgres service so we can modify the + # command line args to include extensions. + # https://github.com/actions/runner/issues/2139 + - name: Start custom postgres service + run: | + ./docker/postgres-latest/up.sh + - name: Download artifact uses: actions/download-artifact@v4 with: diff --git a/.gitignore b/.gitignore index da45607e2..756c1fb4f 100644 --- a/.gitignore +++ b/.gitignore @@ -55,4 +55,6 @@ build/ # vim swap files .*.swp -.env \ No newline at end of file +.env + +docker-compose-*.tar.gz diff --git a/docker/postgres-latest/docker-compose.yml b/docker/postgres-latest/docker-compose.yml index 982a2b517..56294cc34 100644 --- a/docker/postgres-latest/docker-compose.yml +++ b/docker/postgres-latest/docker-compose.yml @@ -6,13 +6,19 @@ services: container_name: postgres hostname: postgres image: postgres:alpine - command: postgres -N 500 + command: postgres -N 500 -c shared_preload_libraries=pg_stat_statements environment: POSTGRES_USER: admin POSTGRES_PASSWORD: password POSTGRES_DB: benchbase ports: - "5432:5432" + healthcheck: + test: pg_isready + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s postgres-ui: container_name: postgres-ui diff --git a/docker/postgres-latest/up.sh b/docker/postgres-latest/up.sh index d05249baf..57aa331f4 100755 --- a/docker/postgres-latest/up.sh +++ b/docker/postgres-latest/up.sh @@ -5,3 +5,21 @@ scriptdir=$(dirname "$(readlink -f "$0")") cd "$scriptdir/" docker compose up -d + +# Wait until ready +for i in {1..30}; do + if docker exec postgres pg_isready; then + break + else + sleep 1 + fi +done + +function run_psql_in_docker() { + set -x + docker exec --env PGPASSWORD=password postgres psql -h localhost -U admin benchbase --csv -c "$@" + set +x +} + +run_psql_in_docker "CREATE EXTENSION pg_stat_statements" +run_psql_in_docker "SELECT COUNT(*) FROM pg_stat_statements" | egrep '^[1-9][0-9]*$' \ No newline at end of file From 1e5614897920650156ab14d8ad208e207c3b10d6 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 10 May 2024 19:34:36 +0000 Subject: [PATCH 3/8] enable advanced monitoring for pg as well --- .github/workflows/maven.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 867d63ec2..1f119e543 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -468,14 +468,14 @@ jobs: # In this case, we load the tpcc data. if [[ ${{matrix.benchmark}} == templated ]]; then java -jar benchbase.jar -b tpcc -c config/postgres/sample_tpcc_config.xml --create=true --load=true --execute=false --json-histograms results/histograms.json - java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/postgres/sample_${{matrix.benchmark}}_config.xml --create=false --load=false --execute=true --json-histograms results/histograms.json + java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/postgres/sample_${{matrix.benchmark}}_config.xml -im 1000 -mt advanced --create=false --load=false --execute=true --json-histograms results/histograms.json elif [[ ${{matrix.benchmark}} == tpcc-with-reconnects ]]; then # See Also: WITH_SERVICE_INTERRUPTIONS=true docker/build-run-benchmark-with-docker.sh java -jar benchbase.jar -b tpcc -c config/postgres/sample_tpcc_config.xml --create=true --load=true (sleep 10 && ./scripts/interrupt-docker-db-service.sh postgres) & - java -jar benchbase.jar -b tpcc -c config/postgres/sample_tpcc_config.xml --execute=true --json-histograms results/histograms.json + java -jar benchbase.jar -b tpcc -c config/postgres/sample_tpcc_config.xml -im 1000 --mt advanced --execute=true --json-histograms results/histograms.json else - java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/postgres/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true --json-histograms results/histograms.json + java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/postgres/sample_${{matrix.benchmark}}_config.xml -im 1000 --mt advanced --create=true --load=true --execute=true --json-histograms results/histograms.json fi # FIXME: Reduce the error rate so we don't need these overrides. @@ -491,6 +491,12 @@ jobs: ./scripts/check_latest_benchmark_results.sh $results_benchmark ./scripts/check_histogram_results.sh results/histograms.json $ERRORS_THRESHOLD + # Running the monitor should create at least three files in the 'monitor' directory. + if ![ $(find "./results/monitor" -maxdepth 1 -mindepth 1 | wc -l) -gt 2]; then + echo "ERROR: Advanced monitoring unsuccessful, file directory and/or appropriate files not created." >&2 + exit 1 + fi + ## ---------------------------------------------------------------------------------- ## COCKROACHDB ## ---------------------------------------------------------------------------------- From 3733b189ef494054351d851512c93fa5658edc26 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 10 May 2024 19:48:15 +0000 Subject: [PATCH 4/8] allow selectively upping services --- .github/workflows/maven.yml | 2 +- docker/postgres-latest/up.sh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0256d2b96..dfc98c6d5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -438,7 +438,7 @@ jobs: # https://github.com/actions/runner/issues/2139 - name: Start custom postgres service run: | - ./docker/postgres-latest/up.sh + ./docker/postgres-latest/up.sh postgres - name: Download artifact uses: actions/download-artifact@v4 diff --git a/docker/postgres-latest/up.sh b/docker/postgres-latest/up.sh index 57aa331f4..2741158cf 100755 --- a/docker/postgres-latest/up.sh +++ b/docker/postgres-latest/up.sh @@ -4,7 +4,9 @@ set -eu scriptdir=$(dirname "$(readlink -f "$0")") cd "$scriptdir/" -docker compose up -d +services="$@" + +docker compose up -d $services # Wait until ready for i in {1..30}; do @@ -22,4 +24,4 @@ function run_psql_in_docker() { } run_psql_in_docker "CREATE EXTENSION pg_stat_statements" -run_psql_in_docker "SELECT COUNT(*) FROM pg_stat_statements" | egrep '^[1-9][0-9]*$' \ No newline at end of file +run_psql_in_docker "SELECT COUNT(*) FROM pg_stat_statements" | egrep '^[1-9][0-9]*$' From 43dacf82c9dd7f82eef5a29250feb600185d19e7 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 10 May 2024 19:49:03 +0000 Subject: [PATCH 5/8] down service --- .github/workflows/maven.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index dfc98c6d5..370587c2c 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -491,6 +491,10 @@ jobs: ./scripts/check_latest_benchmark_results.sh $results_benchmark ./scripts/check_histogram_results.sh results/histograms.json $ERRORS_THRESHOLD + - name: Stop custom postgres service + run: | + ./docker/postgres-latest/down.sh + ## ---------------------------------------------------------------------------------- ## COCKROACHDB ## ---------------------------------------------------------------------------------- From f41255eccbc2854da2286e5eb7a2cd5df97768bd Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 10 May 2024 20:06:37 +0000 Subject: [PATCH 6/8] fixup --- docker/postgres-latest/up.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/postgres-latest/up.sh b/docker/postgres-latest/up.sh index 2741158cf..6acd12517 100755 --- a/docker/postgres-latest/up.sh +++ b/docker/postgres-latest/up.sh @@ -23,5 +23,5 @@ function run_psql_in_docker() { set +x } -run_psql_in_docker "CREATE EXTENSION pg_stat_statements" +run_psql_in_docker "CREATE EXTENSION IF NOT EXISTS pg_stat_statements" run_psql_in_docker "SELECT COUNT(*) FROM pg_stat_statements" | egrep '^[1-9][0-9]*$' From 9231f1c4af6e03dad198e2826a168223a65d84a6 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 10 May 2024 20:19:46 +0000 Subject: [PATCH 7/8] tweaks --- docker/postgres-latest/up.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/postgres-latest/up.sh b/docker/postgres-latest/up.sh index 6acd12517..540439c32 100755 --- a/docker/postgres-latest/up.sh +++ b/docker/postgres-latest/up.sh @@ -9,11 +9,11 @@ services="$@" docker compose up -d $services # Wait until ready -for i in {1..30}; do - if docker exec postgres pg_isready; then +for i in {1..5}; do + if docker exec postgres pg_isready && sleep 2 && docker exec postgres pg_isready; then break else - sleep 1 + sleep 5 fi done From 848887055d7b098155d7b2d9d147d9394759fe90 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 10 May 2024 20:22:21 +0000 Subject: [PATCH 8/8] quiet --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 05ff2a6df..41d6ed456 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -438,7 +438,7 @@ jobs: # https://github.com/actions/runner/issues/2139 - name: Start custom postgres service run: | - ./docker/postgres-latest/up.sh postgres + ./docker/postgres-latest/up.sh --quiet-pull postgres - name: Download artifact uses: actions/download-artifact@v4