Skip to content
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
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ PG_USER=postgres
PG_PASSWORD=postgres
PG_DATABASE=postgres

PG2_HOST=host.docker.internal
PG2_PORT=5437
PG2_USER=postgres
PG2_PASSWORD=postgres
PG2_DATABASE=postgres

PEERDB_CATALOG_HOST=host.docker.internal
PEERDB_CATALOG_PORT=9901
PEERDB_CATALOG_USER=postgres
Expand Down
46 changes: 44 additions & 2 deletions .github/workflows/flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
catalog2:
image: imresamu/postgis:${{ matrix.db-version.pg }}-3.5-alpine
ports:
- 5437:5432
env:
PGUSER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_INITDB_ARGS: --locale=C.UTF-8
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redpanda:
image: redpandadata/redpanda@sha256:12ddbd8e5572210a48d39afecac44db61503ce1cbdae50ee9b1ff5998a8d91e1
ports:
Expand Down Expand Up @@ -111,11 +125,23 @@ jobs:
go-version: '1.26.2'
cache-dependency-path: flow/go.sum

- name: install lib-geos
- name: install lib-geos and pg_dump
run: |
# No need to update man pages on package install
sudo apt-get remove --purge man-db
sudo apt-get install libgeos-dev
# Add PGDG apt repo for latest PostgreSQL client packages
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc \
--fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] \
https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
| sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
sudo apt-get install -y libgeos-dev
# pg_dump must be >= the server major version; install v18 so it
# can dump PG 16, 17, and 18 (backward compatible).
sudo apt-get install -y postgresql-client-18
echo /usr/lib/postgresql/18/bin >> $GITHUB_PATH

- name: install retry tool
run: |
Expand Down Expand Up @@ -275,6 +301,17 @@ jobs:
env:
PGPASSWORD: postgres

- name: prepare secondary postgres for cross-cluster schema-dump tests
run: >
docker exec "${{ job.services.catalog2.id }}" psql -U postgres
-c "ALTER SYSTEM SET wal_level=logical;"
-c "ALTER SYSTEM SET max_replication_slots=192;"
-c "ALTER SYSTEM SET max_wal_senders=256;"
-c "ALTER SYSTEM SET max_connections=2048;" &&
docker restart "${{ job.services.catalog2.id }}"
env:
PGPASSWORD: postgres

- name: set ClickHouse version
id: ch-version
run: |
Expand Down Expand Up @@ -561,6 +598,11 @@ jobs:
PG_USER: postgres
PG_PASSWORD: postgres
PG_DATABASE: postgres
PG2_HOST: localhost
PG2_PORT: 5437
PG2_USER: postgres
PG2_PASSWORD: postgres
PG2_DATABASE: postgres
PEERDB_SWITCHBOARD_ENABLED: "true"
PEERDB_QUEUE_FORCE_TOPIC_CREATION: "true"
ELASTICSEARCH_TEST_ADDRESS: http://localhost:9200
Expand Down
11 changes: 11 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ local_resource(
resource_deps=['postgres']
)

local_resource(
'provision-postgres2',
cmd='./local_provision_scripts/postgres.sh peerdb-postgres2',
labels=['Ancillary-DB-Provisioning'],
resource_deps=['postgres2']
)

# This is not defined as a resource as we need the file to be present
# when `docker_compose` loads the configuration (next line).
local('./generate-test-environment.sh')
Expand Down Expand Up @@ -150,6 +157,10 @@ dc_resource('postgres', labels=['Ancillary-DB'], links=[
link('http://localhost:5432', 'PostgreSQL'),
], auto_init=False)

dc_resource('postgres2', labels=['Ancillary-DB'], links=[
link('http://localhost:5437', 'PostgreSQL (secondary)'),
], auto_init=False)

local_resource(
'all-test-resources',
cmd=' '.join([
Expand Down
22 changes: 22 additions & 0 deletions ancillary-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,27 @@ services:
timeout: 10s
retries: 5

postgres2:
container_name: peerdb-postgres2
image: ${POSTGRES_IMAGE}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a change request, I'd rather keep it simpler, but I wonder if you foresee needing to test different PG versions in source and destination.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that's a great shout @pfcoperez, would probably need to test PG16 to PG18 type mirrors

restart: unless-stopped
volumes:
- postgres2_data:/var/lib/postgresql/data
ports:
- "${PG2_PORT}:5432"
environment:
PGUSER: ${PG2_USER}
POSTGRES_PASSWORD: ${PG2_PASSWORD}
POSTGRES_DB: ${PG2_DATABASE}
POSTGRES_INITDB_ARGS: --locale=C.UTF-8
extra_hosts:
- "host.docker.internal:host-gateway"
healthcheck:
test: ["CMD", "pg_isready"]
interval: 2s
timeout: 10s
retries: 5

dozzle:
container_name: dozzle-compose-monitor
image: amir20/dozzle:latest
Expand Down Expand Up @@ -185,6 +206,7 @@ services:

volumes:
postgres_data:
postgres2_data:
clickhouse_data:
mongo_data:
mysql_gtid_data:
Expand Down
24 changes: 20 additions & 4 deletions local_provision_scripts/postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@ SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
. "$SCRIPT_DIR/../.env"

DOCKER="docker"
CONTAINER="peerdb-postgres"
CONTAINER="${1:-peerdb-postgres}"

# select per-instance vars based on container name
case "$CONTAINER" in
peerdb-postgres2)
PG_INSTANCE_USER="$PG2_USER"
PG_INSTANCE_DATABASE="$PG2_DATABASE"
PG_INSTANCE_HOST="$PG2_HOST"
PG_INSTANCE_PORT="$PG2_PORT"
;;
*)
PG_INSTANCE_USER="$PG_USER"
PG_INSTANCE_DATABASE="$PG_DATABASE"
PG_INSTANCE_HOST="$PG_HOST"
PG_INSTANCE_PORT="$PG_PORT"
;;
esac

echo "install pgvector extension"
if ! $DOCKER exec "$CONTAINER" test -d /tmp/pgvector; then
Expand All @@ -16,7 +32,7 @@ if ! $DOCKER exec "$CONTAINER" test -d /tmp/pgvector; then
fi

echo "create extensions and configure replication"
$DOCKER exec "$CONTAINER" psql -U "$PG_USER" -d "$PG_DATABASE" \
$DOCKER exec "$CONTAINER" psql -U "$PG_INSTANCE_USER" -d "$PG_INSTANCE_DATABASE" \
-c "CREATE EXTENSION IF NOT EXISTS hstore;" \
-c "CREATE EXTENSION IF NOT EXISTS vector;" \
-c "ALTER SYSTEM SET wal_level=logical;" \
Expand All @@ -25,9 +41,9 @@ $DOCKER exec "$CONTAINER" psql -U "$PG_USER" -d "$PG_DATABASE" \
-c "ALTER SYSTEM SET max_connections=2048;"

echo "restart postgres to apply config changes"
CURRENT_WAL=$($DOCKER exec "$CONTAINER" psql -U "$PG_USER" -d "$PG_DATABASE" -tAc "SHOW wal_level;")
CURRENT_WAL=$($DOCKER exec "$CONTAINER" psql -U "$PG_INSTANCE_USER" -d "$PG_INSTANCE_DATABASE" -tAc "SHOW wal_level;")
if [ "$CURRENT_WAL" != "logical" ]; then
$DOCKER restart "$CONTAINER"
fi

echo "PostgreSQL is ready at ${PG_HOST}:${PG_PORT}"
echo "PostgreSQL is ready at ${PG_INSTANCE_HOST}:${PG_INSTANCE_PORT}"
Loading