From 46195685f7fa5d5cf674513fc1f0ffe251343179 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik <37010174+vitabaks@users.noreply.github.com> Date: Thu, 19 Sep 2024 18:38:45 +0300 Subject: [PATCH] Add pgvectorscale extension (#762) --- automation/molecule/default/converge.yml | 2 + .../roles/packages/tasks/extensions.yml | 44 +++++++++++++++++++ .../roles/pre-checks/tasks/extensions.yml | 20 +++++++++ automation/vars/Debian.yml | 3 ++ automation/vars/RedHat.yml | 3 ++ 5 files changed, 72 insertions(+) diff --git a/automation/molecule/default/converge.yml b/automation/molecule/default/converge.yml index 364fe814b..27248f77a 100644 --- a/automation/molecule/default/converge.yml +++ b/automation/molecule/default/converge.yml @@ -62,11 +62,13 @@ enable_pg_partman: true enable_citus: "{{ 'false' if ansible_distribution_version == '24.04' else 'true' }}" # TODO Ubuntu 24.04 enable_paradedb: "{{ 'false' if ansible_distribution_release == 'bullseye' else 'true' }}" # pg_search and pg_analytics (no packages for debian 11) + enable_pgvectorscale: "{{ 'true' if ansible_distribution_release in ['bookworm', 'jammy', 'noble'] else 'false' }}" # only deb packages are available # create extension postgresql_schemas: - { schema: "paradedb", db: "postgres", owner: "postgres" } # pg_search must be installed in the paradedb schema. postgresql_extensions: - { ext: "vector", db: "postgres" } + - { ext: "vectorscale", db: "postgres" } - { ext: "pg_search", db: "postgres", schema: "paradedb" } - { ext: "pg_analytics", db: "postgres" } # - { ext: "", db: "" } diff --git a/automation/roles/packages/tasks/extensions.yml b/automation/roles/packages/tasks/extensions.yml index ab40ee471..f052afc66 100644 --- a/automation/roles/packages/tasks/extensions.yml +++ b/automation/roles/packages/tasks/extensions.yml @@ -233,11 +233,55 @@ retries: 3 when: - (enable_pgvector | default(false)| bool) or + (enable_pgvectorscale | default(false) | bool) or (enable_paradedb | default(false) | bool) - (ansible_os_family == 'Debian' and pg_version | default(postgresql_version) | int >= 11) or (ansible_os_family == 'RedHat' and pg_version | default(postgresql_version) | int >= 12) tags: pgvector +# pgvectorscale - https://github.com/timescale/pgvectorscale +# (if 'enable_pgvectorscale' is 'true') +- block: + - name: Looking up the latest version of pgvectorscale + ansible.builtin.set_fact: + pgvectorscale_version: >- + {{ + (lookup('url', 'https://api.github.com/repos/timescale/pgvectorscale/releases/latest', split_lines=False) + | from_json).get('tag_name') + | replace('v', '') + }} + when: pgvectorscale_version | default('latest') == 'latest' + + - name: Download pgvectorscale archive + ansible.builtin.get_url: + url: "{{ pgvectorscale_repo }}/{{ pgvectorscale_archive }}" + dest: "/tmp/{{ pgvectorscale_archive }}" + timeout: 60 + validate_certs: false + + - name: Extract pgvectorscale package + ansible.builtin.unarchive: + src: "/tmp/{{ pgvectorscale_archive }}" + dest: "/tmp/" + remote_src: true + + # Debian (only deb packages are available) + - name: "Install pgvectorscale v{{ pgvectorscale_version }} package" + ansible.builtin.apt: + deb: "/tmp/{{ pgvectorscale_package }}" + register: apt_status + until: apt_status is success + delay: 5 + retries: 3 + vars: + pgvectorscale_repo: "https://github.com/timescale/pgvectorscale/releases/download/{{ pgvectorscale_version }}" + pgvectorscale_archive: "pgvectorscale-{{ pgvectorscale_version }}-pg{{ pg_version | default(postgresql_version) }}-amd64.zip" # yamllint disable rule:line-length + pgvectorscale_package: "pgvectorscale-postgresql-{{ pg_version | default(postgresql_version) }}_{{ pgvectorscale_version }}-Linux_amd64.deb" # yamllint disable rule:line-length + when: + - enable_pgvectorscale | default(false) | bool + - ansible_os_family == "Debian" + - ansible_distribution_release in ['bookworm', 'jammy', 'noble'] + # ParadeDB (pg_search, pg_analytics) - https://github.com/paradedb/paradedb # (if 'enable_paradedb' or 'enable_pg_search', 'enable_pg_analytics' is 'true') - block: diff --git a/automation/roles/pre-checks/tasks/extensions.yml b/automation/roles/pre-checks/tasks/extensions.yml index ed684fecf..ca41ef0c3 100644 --- a/automation/roles/pre-checks/tasks/extensions.yml +++ b/automation/roles/pre-checks/tasks/extensions.yml @@ -13,6 +13,26 @@ - (enable_timescale | default(false) | bool) or (enable_timescaledb | default(false) | bool) - postgresql_version | string is version(timescale_minimal_pg_version | default(12) | string, '<') +- name: Timescale (pgvectorscale) | Checking PostgreSQL version + run_once: true + ansible.builtin.fail: + msg: + - "The current PostgreSQL version ({{ postgresql_version }}) is not supported by the pgvectorscale." + - "PostgreSQL version must be {{ pgvectorscale_minimal_pg_version | default(15) }} or higher." + when: + - enable_pgvectorscale | default(false) | bool + - postgresql_version | string is version(pgvectorscale_minimal_pg_version | default(15) | string, '<') + +- name: Timescale (pgvectorscale) | Checking supported operating system and version + run_once: true + ansible.builtin.fail: + msg: + - "pgvectorscale is not supported on {{ ansible_distribution }} {{ ansible_distribution_release }}." + - "Supported OS: Debian (bookworm), Ubuntu (jammy, noble)." + when: + - enable_pgvectorscale | default(false) | bool + - not (ansible_os_family == "Debian" and ansible_distribution_release in ['bookworm', 'jammy', 'noble']) + - name: ParadeDB | Checking PostgreSQL version run_once: true ansible.builtin.fail: diff --git a/automation/vars/Debian.yml b/automation/vars/Debian.yml index daead7640..e0b076795 100644 --- a/automation/vars/Debian.yml +++ b/automation/vars/Debian.yml @@ -50,6 +50,9 @@ system_packages: - acl - dnsutils - moreutils + - unzip + - tar + - zstd install_perf: false # or 'true' to install "perf" (Linux profiling with performance counters) and "FlameGraph". diff --git a/automation/vars/RedHat.yml b/automation/vars/RedHat.yml index 816594dfe..f838ed97d 100644 --- a/automation/vars/RedHat.yml +++ b/automation/vars/RedHat.yml @@ -69,6 +69,9 @@ system_packages: - acl - bind-utils - moreutils + - unzip + - tar + - zstd install_perf: false # or 'true' to install "perf" (Linux profiling with performance counters) and "FlameGraph".