timescale/timescaledb-docker

data loss when upgrading timescale version

ecthiender opened this issue · 2 comments

What

When updating the image tag of an existing running docker-compose service, and then running docker compose up, the new image wipes all existing data.

Expected behaviour

New version of timescale image retains older data. If data directory is not compatible with new version, then it should report a FATAL error, instead of wiping out existing data.

Steps to reproduce

  1. Simple docker compose file for a timescaledb service
services:
  timescaledb:
    image: timescale/timescaledb-ha:pg16.4-ts2.17.1
    ports:
      - 7432:5432
    environment:
      POSTGRES_PASSWORD: "password"
    volumes:
      - pg_data:/var/lib/postgresql/data

volumes:
  pg_data:

Start the service - docker compose up -d

  1. Connect via psql, and create a hypertable and insert data
CREATE TABLE measurements (
  timestamp TIMESTAMPTZ NOT NULL,
  temperature DOUBLE PRECISION
);

SELECT create_hypertable('measurements', by_range('timestamp'));

INSERT INTO measurements (timestamp, temperature) VALUES (now(), 22.3), (now(), 18.2), (now(), 25.2);
  1. Check data is inserted and can be queried.

  2. Update timescale version in docker compose

    image: timescale/timescaledb-ha:pg16.6-ts2.17.2
  1. Run docker compose up -d

  2. Connect via psql again and run \dt. There no tables anymore.

@ecthiender The PGDATA directory for timescaledb-ha is /home/postgres/pgdata/data. Please mount this instead of /var/lib/postgresql/data in your docker compose file, this should fix it.

@kpan2034
Yeah I eventually figured that out. Why this weird disparity?

Your regular timescaledb image has PGDATA as /var/lib/postgresql, so why some random path for timescaldb-ha?

You do have a note it in your docs, but it is buried somewhere deep in the page. You should keep that at the top of the page. As the consequence can be catastrophic to your customers.

The problem you have is you make it very easy to do the wrong thing for your user. And they suffer. And from your github issues, threads, doesn't look like you have much empathy towards your users. I don't see any remorse that your users suffer data loss. You just shrug it off by saying "user error - they don't know how to configure it correctly". But have you ever wondered, that your weird configuration is what has a direct impact on the DX and your users?

If you really want to build a slick product that your users love, MAKE THE WRONG THING HARD TO DO. And make the right thing easy to do.

Anyway, this is my 2 cents, from my experience.