From c8a3c56ac3de528f826b7dd1b8270e3a710f9fd7 Mon Sep 17 00:00:00 2001 From: Feike Steenbergen Date: Mon, 27 Nov 2023 09:32:32 +0100 Subject: [PATCH 1/4] Skip PostgreSQL 12 by default for CICD TimescaleDB 2.13.0 does not support PostgreSQL 12 anymore. This currently causes our CI to fail. To still be able to test PostgreSQL 12, we will run it if the TimescaleDB tag is set to 2.11.2 https://docs.timescale.com/about/latest/release-notes/#timescaledb-2120-on-2023-09-27 --- .github/workflows/ci.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f783bd98..e0b7981d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: fail-fast: false max-parallel: 12 matrix: - pgversion: [12, 13, 14, 15, 16] + pgversion: [13, 14, 15, 16] container: - os: rockylinux version: "9" @@ -80,6 +80,17 @@ jobs: os: centos version: "7" pgversion: 16 + # TimescaleDB as of 2.12.0 no longer supports PostgreSQL 12. + # To allow us to do run CI against PostgreSQL 12, we therefore explicitly + # remove all CI's, except if we are run against the latest supported TimescaleDB + # version for PostgreSQL 12, which is 2.11.2 + include: + - pgversion: 12 + container: + image: debian-11-amd64 + os: debian + version: "11" + tsdb_commit: 2.11.2 env: # TODO Why? Cargo default is to pass `-C incremental` to rustc; why don't we want that? # https://doc.rust-lang.org/rustc/codegen-options/index.html#incremental @@ -113,7 +124,7 @@ jobs: - name: Build and install TimescaleDB if: ${{ (github.event_name == 'schedule' && github.event.schedule == '0 8 * * 1-4') || inputs.tsdb-commit != '' }} - run: ./tools/install-timescaledb '${{ matrix.pgversion }}' '${{ inputs.tsdb-repo || 'https://github.com/timescale/timescaledb.git' }}' '${{ inputs.tsdb-commit == '' && 'main' || inputs.tsdb-commit }}' + run: ./tools/install-timescaledb '${{ matrix.pgversion }}' '${{ matrix.tsdb_commit || inputs.tsdb-repo || 'https://github.com/timescale/timescaledb.git' }}' '${{ inputs.tsdb-commit == '' && 'main' || matrix.tsdb_commit || inputs.tsdb-commit }}' # TODO After the container image contains a primed target dir, is this still worth it? # Only possible advantage is this one is per-pg-version but what's the impact? From 39ed29013ca9fb513ac9dd3f33cc1995a4dda82f Mon Sep 17 00:00:00 2001 From: Feike Steenbergen Date: Mon, 27 Nov 2023 10:16:58 +0100 Subject: [PATCH 2/4] Skip timescaledb for PostgreSQL 12 @ Debian 12 --- docker/ci/setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker/ci/setup.sh b/docker/ci/setup.sh index 250c2e4f..d56772ae 100755 --- a/docker/ci/setup.sh +++ b/docker/ci/setup.sh @@ -147,6 +147,11 @@ EOF # Debian family debian | ubuntu) + # TimescaleDB does not have packages for Debian 12 + if [[ $OS_VERSION -ge 12 ]]; then + export TSDB_PG_VERSIONS="13 14 15" + fi + # Image comes in with no package lists so we have to start with this. apt-get -qq update From 0953c2b027690cf3689411f70e291ae158e0124f Mon Sep 17 00:00:00 2001 From: Feike Steenbergen Date: Mon, 27 Nov 2023 10:20:41 +0100 Subject: [PATCH 3/4] Do not install PostgreSQL 16 on centos 7 --- docker/ci/setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/ci/setup.sh b/docker/ci/setup.sh index d56772ae..701757d1 100755 --- a/docker/ci/setup.sh +++ b/docker/ci/setup.sh @@ -54,6 +54,8 @@ if $privileged; then centos | rockylinux) case $OS_VERSION in 7) + export PG_VERSIONS="13 14 15" + export TSDB_PG_VERSIONS="13 14 15" # Postgresql packages require both # - llvm-toolset-7-clang from centos-release-scl-rh # - llvm5.0-devel from epel-release From 67ec93c44c140c5a27225e854dd65d91c3369b54 Mon Sep 17 00:00:00 2001 From: Feike Steenbergen Date: Mon, 27 Nov 2023 11:12:38 +0100 Subject: [PATCH 4/4] Initialize Cargo / timescaledb only if available Previously, we depended on the value of PG_VERSIONS or TSDB_PG_VERSIONS. This doesn't always work correctly, however, we can switch to determining the versions at runtime, that should prevent errors like: 528.1 + for pg in '$PG_VERSIONS' 528.1 + init_flags=' --pg12 /usr/pgsql-12/bin/pg_config --pg13 /usr/pgsql-13/bin/pg_config --pg14 /usr/pgsql-14/bin/pg_config --pg15 /usr/pgsql-15/bin/pg_config --pg16 /usr/pgsql-16/bin/pg_config' 528.1 + cargo pgrx init --pg12 /usr/pgsql-12/bin/pg_config --pg13 /usr/pgsql-13/bin/pg_config --pg14 /usr/pgsql-14/bin/pg_config --pg15 /usr/pgsql-15/bin/pg_config --pg16 /usr/pgsql-16/bin/pg_config 528.1 Creating PGRX_HOME at `/home/postgres/.pgrx` 528.1 The application panicked (crashed). 528.1 Message: no major version: 528.1 0: The specified pg_config binary, `/usr/pgsql-16/bin/pg_config`, does not exist 528.1 1: No such file or directory (os error 2) --- docker/ci/setup.sh | 63 +++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/docker/ci/setup.sh b/docker/ci/setup.sh index 701757d1..0f8345cb 100755 --- a/docker/ci/setup.sh +++ b/docker/ci/setup.sh @@ -150,7 +150,7 @@ EOF # Debian family debian | ubuntu) # TimescaleDB does not have packages for Debian 12 - if [[ $OS_VERSION -ge 12 ]]; then + if [ $OS_VERSION -ge 12 ]; then export TSDB_PG_VERSIONS="13 14 15" fi @@ -204,28 +204,28 @@ EOF apt-get -qq update - for pg in $PG_VERSIONS; do - apt-get -qq install \ - postgresql-$pg \ - postgresql-server-dev-$pg - # We install as user postgres, so that needs write access to these. - chown $BUILDER_USERNAME $PG_BASE$pg/lib /usr/share/postgresql/$pg/extension - done - - for pg in $TSDB_PG_VERSIONS; do - # timescaledb packages Recommend toolkit, which we don't want here. - apt-get -qq install --no-install-recommends timescaledb-2-postgresql-$pg - done - - # Ubuntu is the only system we want an image for that sticks an extra - # copy of the default PATH into PAM's /etc/environment and we su or sudo - # to $BUILDER_USERNAME thereby picking up that PATH and clobbering the - # one we set in Dockerfile. There's nothing else in here, so at first I - # thought to remove it. That works on 20.04 and 22.04, but still leaves - # a busted PATH on 18.04! On 18.04, we get clobbered by ENV_PATH in - # /etc/login.defs . We fix all three by setting our PATH here: - echo > /etc/environment "PATH=$PATH" - ;; + for pg in $PG_VERSIONS; do + apt-get -qq install \ + postgresql-$pg \ + postgresql-server-dev-$pg + # We install as user postgres, so that needs write access to these. + chown $BUILDER_USERNAME $PG_BASE$pg/lib /usr/share/postgresql/$pg/extension + done + + for pg in $TSDB_PG_VERSIONS; do + # timescaledb packages Recommend toolkit, which we don't want here. + apt-get -qq install --no-install-recommends timescaledb-2-postgresql-$pg + done + + # Ubuntu is the only system we want an image for that sticks an extra + # copy of the default PATH into PAM's /etc/environment and we su or sudo + # to $BUILDER_USERNAME thereby picking up that PATH and clobbering the + # one we set in Dockerfile. There's nothing else in here, so at first I + # thought to remove it. That works on 20.04 and 22.04, but still leaves + # a busted PATH on 18.04! On 18.04, we get clobbered by ENV_PATH in + # /etc/login.defs . We fix all three by setting our PATH here: + echo > /etc/environment "PATH=$PATH" + ;; esac # Phase 3 - cross-platform privileged tasks after package installation @@ -252,13 +252,20 @@ cargo install cargo-pgrx --version =$PGRX_VERSION # Configure pgrx ## `cargo pgrx init` is not additive; must specify all versions in one command. -for pg in $PG_VERSIONS; do - init_flags="$init_flags --pg$pg $PG_BASE$pg/bin/pg_config" +for pg_config in $(find /usr -name 'pg_config' -type f | grep "${PG_BASE}"); do + pg="$(${pg_config} --version | awk -F '[ .]' '{print $2'})" + init_flags="$init_flags --pg$pg ${pg_config}" done cargo pgrx init $init_flags -## Initialize pgrx-managed databases so we can add the timescaledb load. -for pg in $TSDB_PG_VERSIONS; do - echo "shared_preload_libraries = 'timescaledb'" >> ~/.pgrx/data-$pg/postgresql.conf + +## Initialize pgrx-managed databases so we can add the timescaledb load, but only +## for those PostgreSQL versions that have the timescaledb.so library available. +for pg_config in $(find /usr -name 'pg_config' -type f | grep "${PG_BASE}"); do + pg="$(${pg_config} --version | awk -F '[ .]' '{print $2'})" + lib="$(find "${PG_BASE}${pg}" -type f -name 'timescaledb.so')" + if [ "${lib}" != "" ]; then + echo "shared_preload_libraries = 'timescaledb'" >> ~/.pgrx/data-$pg/postgresql.conf + fi done # Clone and fetch dependencies so we builds have less work to do.