timescale / timescaledb-docker

Release Docker builds of TimescaleDB
Apache License 2.0
290 stars 128 forks source link

Running this image as replica with mounted volume or static volume fails #227

Open peza opened 9 months ago

peza commented 9 months ago

With guide from official documentation https://docs.timescale.com/self-hosted/latest/replication-and-ha/configure-replication/ pointing to https://github.com/timescale/streaming-replication-docker/blob/master/replication.sh the process fails with "rm: can't remove '/var/lib/postgresql/data/pgdata': Resource busy" on line 44 "rm -rf ${PGDATA}" of the replication.sh file.

I've also updated the Dockerfile to use version 16 instead of 10, which made me comment the lines 66 to 74 of replication.sh and adding cat >> ${PGDATA}/postgresql.conf <<EOF primary_conninfo = 'host=${REPLICATE_FROM} port=5432 user=${POSTGRES_USER} password=${POSTGRES_PASSWORD} application_name=${REPLICA_NAME}' primary_slot_name = '${REPLICA_NAME}_slot' EOF

below commented lines, to conform to official TimescaleDB documentation.

This docker image prevents deleting the folder if static volume is used. docker run --name timescale-replica -p 5433:5432 --network timescale-replication --env-file replica.env -v replica:/var/lib/postgresql/data/pgdata timescale-replica or docker run -d --name timescale-replica -p 5433:5432 --network timescale-replication --env-file replica.env -v replica:/var/lib/postgresql/data/pgdata timescale/timescaledb:latest-pg16 to use the original docker image Creating a replica with static or mounted volume from this docker image is not possible

peza commented 9 months ago

workaround for the issue is to add / at the end (rm -rf ${PGDATA}/) of line 44 "rm -rf ${PGDATA}" of the replication.sh file in https://github.com/timescale/streaming-replication-docker/blob/master/replication.sh

jnidzwetzki commented 9 months ago

Hello @peza,

Thank you for bringing this to our attention and providing the workaround.

The streaming-replication-docker repository contains an outdated example for setting up replication. We will deprecate this repository soon. We have already removed the link from our documentation (https://github.com/timescale/docs/pull/2894). Please have a look at our Helm Charts for a more advanced and more recent configuration (https://github.com/timescale/helm-charts/tree/main/charts/timescaledb-single).