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

Sam/oriole17 #1298

Draft
wants to merge 77 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
cdc6452
feat: build and flake check of pg 16.3 with exts/wrappers
Oct 7, 2024
91ec362
pg_partman test 15/16 compat
olirice Oct 7, 2024
0321dfa
merge sql interface test
olirice Oct 7, 2024
aa5dd9a
tests: build test and cache both versions
Oct 7, 2024
65fdc5d
chore: run checks individually
Oct 7, 2024
f10881b
pg 15 and 16 packer/ansible/ghactions (#1268)
samrose Oct 10, 2024
7f7730e
chore: rm dead code
Oct 10, 2024
3454b62
chore: resolve versions from ansible/vars.yml instead of packer file
Oct 15, 2024
d576b01
feat: WIP orioledb 16
Oct 15, 2024
ce43530
feat: intro into CI building psql16 bundle oriole version
Oct 15, 2024
b6fdd11
test: working through build compat for oriole
Oct 16, 2024
859cbca
working orioledb build
Oct 17, 2024
a4b4998
fix: update value
Oct 17, 2024
6336dba
Merge branch 'develop' into sam/oriole16
samrose Oct 17, 2024
8c13a58
chore: cut staging only release for oriole16
Oct 17, 2024
07117e3
narrow down to just oriole staging ami here
Oct 17, 2024
9f4b869
Merge branch 'develop' into sam/oriole16
samrose Oct 17, 2024
2ea1e90
fix: make sure name lines up with gh action convention
Oct 17, 2024
c7f68df
fix: get correct naming convention in here too for oriole bundle
Oct 17, 2024
870f591
chore: bump to cut release
Oct 17, 2024
d483a07
fix: make sure src and debug builds available for oriole too
Oct 17, 2024
5e69b00
chore: bump to staging release
Oct 17, 2024
b62e770
fix: when oriole16 rm timescale from supautils conf
Oct 17, 2024
889dc70
fix: also remove from postgresql conf
Oct 18, 2024
a67d8e1
fix: find all instances and remove in this condition for tiemscaledb
Oct 18, 2024
67382a6
fix: maybe broke pgsodium with too many spaces
Oct 18, 2024
c08b661
fix: create a symlink for missing path
Oct 18, 2024
59b44b6
fix: try a more universal way to deactivate pgsodium at this stage
Oct 18, 2024
f961371
chore: when oriole16 rm timescale plv8 postgis pgvector pgrouting
Oct 18, 2024
a8f1a6b
fix: more handling of oriole16 differences
Oct 18, 2024
c35fa68
chore more oriole16 handling
Oct 18, 2024
d1e06d4
fix: refine sed regex
Oct 18, 2024
304aa68
fix: also cond rm actual files
Oct 18, 2024
55b9763
fix: correct dir
Oct 18, 2024
292327e
chore: bump to release
Oct 18, 2024
32163be
feat: parse and handle oropledb-16 in start-server
Oct 21, 2024
e1c199c
feat: start-client for oriole16
samrose Oct 21, 2024
6a5648b
wip for orioledb push to build on linux
Oct 22, 2024
049010a
fix: running server
samrose Oct 22, 2024
c2e2801
chore: consolidate nix code that handles building of postgres versions
samrose Oct 23, 2024
1cd2063
fix: update name for bundle
samrose Oct 23, 2024
0e23e7d
chore: small cleanup
Oct 24, 2024
f6cbbe7
Merge branch 'develop' into sam/oriole16
samrose Oct 24, 2024
9d48e50
chore: bump version release
Oct 24, 2024
25e1b3b
Merge branch 'develop' into sam/oriole16
samrose Oct 24, 2024
fed90a0
chore: cleanup names
Oct 24, 2024
9b078d0
chore: correct names
Oct 24, 2024
bc2b4cc
fix: var name
samrose Oct 24, 2024
12dc397
fix: one more var name
samrose Oct 24, 2024
73944e1
chore: bump to release
samrose Oct 24, 2024
9ae9c9f
fix: reformatting metadata for clikchouse dep as git was not able to …
Oct 24, 2024
fa05170
feat: wip refactor to pg 17 for orioledb
Oct 24, 2024
0e283e6
feat: working orioledb-17
samrose Oct 25, 2024
051c9fd
fix: increase role duration to avoid expiration
Oct 27, 2024
33b8948
fix: correct version
Oct 27, 2024
230c7c7
fix: clickhouse needs git in build inputs
Oct 28, 2024
ee4ce32
fix: install and then remove git for clickhouse dep
Oct 28, 2024
2ccb5ac
fix: correct rules for version
Oct 28, 2024
f9cadcc
fix: db_user_namespace was deprecated starting in pg 16.4 and higher
Oct 28, 2024
1c9c1f1
apply fix for wrappers build, deactivate ext in unit test
Oct 28, 2024
d02197e
Merge branch 'develop' into sam/oriole17
samrose Oct 28, 2024
2f0186f
chore: deactivate more tests due to deactivated extensions
Oct 28, 2024
4ac77c4
fix: also remove from sql file
Oct 28, 2024
61434e0
fix: regex
Oct 28, 2024
24b7442
fix: also remove ref here
Oct 29, 2024
9ec0bfa
fix: graphql_public schema too
Oct 29, 2024
37d6e49
chore: correct dir
Oct 29, 2024
45de660
chore: staging release
Oct 29, 2024
dd649cc
feat: re-introduce wal2json rum and pgvector
samrose Oct 29, 2024
a1efc9b
fix: also restore pgvector in start-server
samrose Oct 29, 2024
feec1e5
chore: bump staging release
samrose Oct 29, 2024
1444882
feat: oriole specific default settings
Oct 30, 2024
2fb7958
feat: use icu for locales only if building orioledb
Oct 30, 2024
2ff3c01
fix: need var in stage 1 too
Oct 30, 2024
18d9116
fix: settings must be in db init
Oct 30, 2024
1d6c728
fix: ansible args
Oct 30, 2024
376f8d9
fix: PostgreSQL uses ICU for all locale-related operations, so we don…
Oct 30, 2024
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
5 changes: 3 additions & 2 deletions .github/workflows/ami-release-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ name: Release AMI Nix
on:
push:
branches:
- develop
- release/*
#- develop
#- release/*
- sam/oriole17
paths:
- '.github/workflows/ami-release-nix.yml'
- 'common-nix.vars.pkr.hcl'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
aws-region: "us-east-1"
output-credentials: true
role-duration-seconds: 7200
- name: write secret key
# use python so we don't interpolate the secret into the workflow logs, in case of bugs
run: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
push:
branches:
- develop
pull_request:
#TODO PR uncomment this line
#pull_request:
workflow_dispatch:

jobs:
Expand Down
60 changes: 43 additions & 17 deletions ansible/tasks/setup-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,49 @@
ansible_command_timeout: 60
when: debpkg_mode

- name: Initialize the database stage2_nix
become: yes
become_user: postgres
shell: source /var/lib/postgresql/.bashrc && /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data initdb -o "--allow-group-access" -o "--username=supabase_admin"
args:
executable: /bin/bash
environment:
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
LC_ALL: en_US.UTF-8
LC_CTYPE: en_US.UTF-8
LOCALE_ARCHIVE: /usr/lib/locale/locale-archive
vars:
ansible_command_timeout: 60
# Circumvents the following error:
# "Timeout (12s) waiting for privilege escalation prompt"
when: stage2_nix
- name: Check psql_version and modify supautils.conf and postgresql.conf if necessary
block:
- name: Check if psql_version is psql_orioledb
set_fact:
is_psql_oriole: "{{ psql_version in ['psql_orioledb-16', 'psql_orioledb-17'] }}"

- name: Initialize the database stage2_nix (non-orioledb)
become: yes
become_user: postgres
shell: source /var/lib/postgresql/.bashrc && initdb -D /var/lib/postgresql/data -o "--allow-group-access" -o "--username=supabase_admin"
args:
executable: /bin/bash
environment:
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
LC_ALL: en_US.UTF-8
LC_CTYPE: en_US.UTF-8
LOCALE_ARCHIVE: /usr/lib/locale/locale-archive
vars:
ansible_command_timeout: 60
when: stage2_nix and not is_psql_oriole

- name: Initialize the database stage2_nix (orioledb)
become: yes
become_user: postgres
shell: >
source /var/lib/postgresql/.bashrc && initdb -D /var/lib/postgresql/data
--allow-group-access
--username=supabase_admin
--locale-provider=icu
--encoding=UTF-8
--icu-locale=en_US.UTF-8
args:
executable: /bin/bash
environment:
LANG: en_US.UTF-8
LANGUAGE: en_US.UTF-8
LC_ALL: en_US.UTF-8
LC_CTYPE: en_US.UTF-8
LOCALE_ARCHIVE: /usr/lib/locale/locale-archive
vars:
ansible_command_timeout: 60
when: stage2_nix and is_psql_oriole

- name: copy PG systemd unit
template:
Expand Down
100 changes: 87 additions & 13 deletions ansible/tasks/stage2-setup-postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,65 @@
# sudo -u postgres bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install nixpkgs#openjdk11"
# It was decided to leave pljava disabled at https://github.com/supabase/postgres/pull/690 therefore removing this task

- name: Check psql_version and modify supautils.conf and postgresql.conf if necessary
block:
- name: Check if psql_version is psql_orioledb-16
set_fact:
is_psql_oriole: "{{ psql_version in ['psql_orioledb-16', 'psql_orioledb-17'] }}"

- name: Remove specified extensions from postgresql.conf if oriole-16 build
ansible.builtin.command:
cmd: >
sed -i 's/ timescaledb,//g'
/etc/postgresql/postgresql.conf
when: is_psql_oriole and stage2_nix
become: yes

- name: Remove specified extensions from supautils.conf if oriole-16 build
ansible.builtin.command:
cmd: >
sed -i 's/ timescaledb,//g; s/ vector,//g; s/ plv8,//g; s/ postgis,//g; s/ pgrouting,//g'
/etc/postgresql-custom/supautils.conf
when: is_psql_oriole and stage2_nix
become: yes

- name: Remove db_user_namespace from postgresql.conf if oriole-xx build
ansible.builtin.command:
cmd: >
sed -i 's/db_user_namespace = off/#db_user_namespace = off/g;'
/etc/postgresql/postgresql.conf
when: is_psql_oriole and stage2_nix
become: yes

- name: Append orioledb to shared_preload_libraries append within closing quote
ansible.builtin.command:
cmd: >
sed -i 's/\(shared_preload_libraries.*\)'\''\(.*\)$/\1, orioledb'\''\2/'
/etc/postgresql/postgresql.conf
when: is_psql_oriole and stage2_nix
become: yes

- name: Add default_table_access_method setting
ansible.builtin.lineinfile:
path: /etc/postgresql/postgresql.conf
line: "default_table_access_method = 'orioledb'"
state: present
when: is_psql_oriole and stage2_nix
become: yes

# TODO PR may need to remove this.
# - name: Add ICU locale settings
# ansible.builtin.lineinfile:
# path: /etc/postgresql/postgresql.conf
# line: "{{ item }}"
# state: present
# with_items:
# - "lc_collate = 'en-US-x-icu'"
# - "lc_ctype = 'en-US-x-icu'"
# - "icu_locale = 'en-US'"
# when: is_psql_oriole and stage2_nix
# become: yes

- name: Install Git for Nix package management
become: yes
apt:
Expand All @@ -16,7 +75,6 @@
become: yes
shell: |
sudo -u postgres bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#{{psql_version}}/bin"
#TODO (samrose) switch pg_prove sourcing to develop branch once PR is merged
when: stage2_nix

- name: Install pg_prove from nix binary cache
Expand All @@ -43,14 +101,15 @@
sudo -u postgres bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#{{postgresql_version}}_src"
when: stage2_nix

- name: Install Git for Nix package management
- name: Remove Git after Nix package installations
become: yes
apt:
name: git
state: present
update_cache: yes
state: absent
autoremove: yes
purge: yes
when: stage2_nix

- name: Set ownership and permissions for /etc/ssl/private
become: yes
file:
Expand Down Expand Up @@ -215,13 +274,19 @@
recurse: yes
when: stage2_nix

- name: Recursively create symbolic links and set permissions for the contrib/postgis-* dir
shell: >
sudo mkdir -p /usr/lib/postgresql/share/postgresql/contrib && \
sudo find /var/lib/postgresql/.nix-profile/share/postgresql/contrib/ -mindepth 1 -type d -exec sh -c 'for dir do sudo ln -s "$dir" "/usr/lib/postgresql/share/postgresql/contrib/$(basename "$dir")"; done' sh {} + \
&& chown -R postgres:postgres "/usr/lib/postgresql/share/postgresql/contrib/"
become: yes
when: stage2_nix
- name: Check psql_version and run postgis linking if not oriole-16
block:
- name: Check if psql_version is psql_orioledb-17
set_fact:
is_psql_oriole: "{{ psql_version == 'psql_orioledb-17' }}"

- name: Recursively create symbolic links and set permissions for the contrib/postgis-* dir
shell: >
sudo mkdir -p /usr/lib/postgresql/share/postgresql/contrib && \
sudo find /var/lib/postgresql/.nix-profile/share/postgresql/contrib/ -mindepth 1 -type d -exec sh -c 'for dir do sudo ln -s "$dir" "/usr/lib/postgresql/share/postgresql/contrib/$(basename "$dir")"; done' sh {} + \
&& chown -R postgres:postgres "/usr/lib/postgresql/share/postgresql/contrib/"
become: yes
when: stage2_nix and not is_psql_oriole

- name: Create symbolic links from /var/lib/postgresql/.nix-profile/share/postgresql/timezonesets to /usr/lib/postgresql/share/postgresql/timeszonesets
file:
Expand Down Expand Up @@ -256,8 +321,17 @@
line: pgsodium.getkey_script= '{{ pg_bindir }}/pgsodium_getkey.sh'
when: stage2_nix

#TODO PR may need to remove this.
- name: Create symbolic link for pgsodium_getkey script
file:
src: "/usr/lib/postgresql/bin/pgsodium_getkey.sh"
dest: "/usr/lib/postgresql/share/postgresql/extension/pgsodium_getkey"
state: link
become: yes
when: stage2_nix

- name: Append GRN_PLUGINS_DIR to /etc/environment.d/postgresql.env
ansible.builtin.lineinfile:
path: /etc/environment.d/postgresql.env
line: 'GRN_PLUGINS_DIR=/var/lib/postgresql/.nix-profile/lib/groonga/plugins'
become: yes
become: yes
71 changes: 70 additions & 1 deletion ansible/tasks/test-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@
- libtap-parser-sourcehandler-pgtap-perl
when: debpkg_mode

# - name: Temporarily disable PG Sodium references in config
# become: yes
# become_user: postgres
# shell:
# cmd: sed -i.bak -e "s/pg_net,\ pgsodium,\ timescaledb/pg_net,\ timescaledb/g" -e "s/pgsodium.getkey_script=/#pgsodium.getkey_script=/g" /etc/postgresql/postgresql.conf
# when: debpkg_mode or stage2_nix

- name: Temporarily disable PG Sodium references in config
become: yes
become_user: postgres
shell:
cmd: sed -i.bak -e "s/pg_net,\ pgsodium,\ timescaledb/pg_net,\ timescaledb/g" -e "s/pgsodium.getkey_script=/#pgsodium.getkey_script=/g" /etc/postgresql/postgresql.conf
cmd: >
sed -i.bak
-e 's/\(shared_preload_libraries = '\''.*\)pgsodium,\(.*'\''\)/\1\2/'
-e 's/pgsodium.getkey_script=/#pgsodium.getkey_script=/'
/etc/postgresql/postgresql.conf
when: debpkg_mode or stage2_nix

- name: Start Postgres Database to load all extensions.
Expand Down Expand Up @@ -46,6 +57,64 @@
LOCALE_ARCHIVE: /usr/lib/locale/locale-archive
when: stage2_nix


- name: Check psql_version and modify migrations if oriole-xx
block:
- name: Check if psql_version is psql_orioledb-xx
set_fact:
is_psql_oriole: "{{ psql_version in ['psql_orioledb-16', 'psql_orioledb-17'] }}"

- name: Remove specified extensions from SQL file
ansible.builtin.command:
cmd: >
sed -i '/\\ir.*\(timescaledb\|postgis\|pgrouting\|plv8\|pg_jsonschema\|pg_graphql\).*\.sql/d' /tmp/migrations/tests/extensions/test.sql
when: is_psql_oriole
become: yes

- name: Remove specified extension files from extensions directory
ansible.builtin.find:
paths: /tmp/migrations/tests/extensions
patterns:
- '*timescaledb*.sql'
- '*postgis*.sql'
- '*pgrouting*.sql'
- '*plv8*.sql'
- '*pg_jsonschema*.sql'
- '*pg_graphql*.sql'
register: files_to_remove
when: is_psql_oriole

- name: Delete matched extension files
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop: "{{ files_to_remove.files }}"
when: is_psql_oriole
become: yes

- name: Remove specified extensions from SQL file
ansible.builtin.command:
cmd: >
sed -i "/'pg_graphql',/d" /tmp/unit-tests/unit-test-01.sql
when: is_psql_oriole
become: yes

- name: Remove graphql schema test
lineinfile:
path: /tmp/migrations/tests/database/exists.sql
regexp: "^SELECT has_schema\\('graphql'\\);$"
state: absent
become: yes
when: is_psql_oriole

- name: Remove graphql schema test
lineinfile:
path: /tmp/migrations/tests/database/exists.sql
regexp: "^SELECT has_schema\\('graphql_public'\\);$"
state: absent
become: yes
when: is_psql_oriole

- name: Run Unit tests (with filename unit-test-*) on Postgres Database
shell: /usr/bin/pg_prove -U postgres -h localhost -d postgres -v /tmp/unit-tests/unit-test-*.sql
register: retval
Expand Down
15 changes: 8 additions & 7 deletions ansible/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ supabase_internal: true
ebssurrogate_mode: true
async_mode: true

# postgresql_major: "15"
# postgresql_release: "15.1"
# postgresql_release_checksum: sha256:ea2cf059a85882654b989acd07edc121833164a30340faee0d3615cf7058e66c
postgres_major:
- "15"
- "16"
#- "15"
#- "16"
- "orioledb-17"

# Full version strings for each major version
# TOD PR uncomment these lines
postgres_release:
postgres15: "15.8.1.004"
postgres16: "16.3.1.010"
#postgres15: "15.8.1.003-staging-5"
#postgres16: "16.3.1.000-staging-5"
#postgresorioledb-16: "orioledb-16.3.1.000-staging-12"
postgresorioledb-17: "orioledb-17.0.1.000-staging-3"

# Non Postgres Extensions
pgbouncer_release: "1.19.0"
Expand Down
4 changes: 4 additions & 0 deletions docker/nix/build_nix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ if [ -d "/workspace" ]; then
fi
nix build .#checks.$(nix-instantiate --eval -E builtins.currentSystem | tr -d '"').psql_15 -L --no-link
nix build .#checks.$(nix-instantiate --eval -E builtins.currentSystem | tr -d '"').psql_16 -L --no-link
#no nix flake check on oriole yet
nix build .#psql_15/bin -o psql_15
nix build .#psql_16/bin -o psql_16
#nix build .#psql_orioledb-16/bin -o psql_orioledb_16
nix build .#psql_orioledb-17/bin -o psql_orioledb_17
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_15
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_16
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_orioledb_17
5 changes: 4 additions & 1 deletion ebssurrogate/scripts/surrogate-bootstrap-nix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ EOF
# Run Ansible playbook
#export ANSIBLE_LOG_PATH=/tmp/ansible.log && export ANSIBLE_DEBUG=True && export ANSIBLE_REMOTE_TEMP=/mnt/tmp
export ANSIBLE_LOG_PATH=/tmp/ansible.log && export ANSIBLE_REMOTE_TEMP=/mnt/tmp
ansible-playbook -c chroot -i '/mnt,' /tmp/ansible-playbook/ansible/playbook.yml --extra-vars '{"nixpkg_mode": true, "debpkg_mode": false, "stage2_nix": false}' $ARGS
ansible-playbook -c chroot -i '/mnt,' /tmp/ansible-playbook/ansible/playbook.yml \
--extra-vars '{"nixpkg_mode": true, "debpkg_mode": false, "stage2_nix": false} ' \
--extra-vars "psql_version=psql_${POSTGRES_MAJOR_VERSION}" \
$ARGS
}

function update_systemd_services {
Expand Down
Loading
Loading