Nextcloud/postgres/redis in docker... collation version mismatch?

Hi all,

I am a total noob with Nextcloud and databases, so please excuse the stupid questions.

I have installed Nextcloud in docker with 3 containers: the main nextcloud, redis, and postgres.
My docker-compose.yaml (redacted for only nextcloud concerning containers) is like this:

version: "3.8"
services:
  nextcloud:
    image: nextcloud:fpm
    container_name: nextcloud
    restart: unless-stopped
    volumes:
      - /home/dietpi/appdata/swag/www/nextcloud:/var/www/html
    environment:
      - POSTGRES_HOST=nextclouddb
      - REDIS_HOST=redis
      - PUID=33
      - PGID=1000
    env_file:
      - db.env
    depends_on:
      - nextclouddb 
      - redis
   
  nextclouddb:
    image: postgres
    container_name: nextclouddb
    restart: unless-stopped
    volumes:
      - /home/dietpi/appdata/nextcloud/db:/var/lib/postgresql/data
    environment:
      - PUID=33
      - PGID=1000
    env_file:
      - db.env
    
  redis:
    image: redis
    container_name: redis
    restart: unless-stopped
    environment:
      - PUID=33
      - PGID=1000

Nextcloud version : 27.0
Operating system and version : RaspberryPi dietpi (debian based)
Apache or nginx version : Using SWAG container from linuxserver.io

Now, everything was working fine until this morning when I updated the containers with docker compose pull. I got new versions of postgres, redis, and nextcloud:fpm

I relaunched the containers with docker compose up -d, and all was well…
… until the cron executed docker exec -u www-data nextcloud php /var/www/html/cron.php

Suddenly I got an error which I don’t understand:

WARNING:  database "nextcloud" has a collation version mismatch
DETAIL:  The database was created using collation version 2.31, but the operating system provides version 2.36.
HINT:  Rebuild all objects in this database that use the default collation and run ALTER DATABASE nextcloud REFRESH COLLATION VERSION, or build PostgreSQL with the right library version.

Could someone explain what this means and how to fix it?
Thank you in advance for your help!

I suspect it means you need to pin your container image versions to at least a proven major version so that they don’t blindly upgrade out from under you. :slight_smile:

You do that using tags on your image references (don’t downgrade however unless you have a data migration strategy!):

https://hub.docker.com/_/postgres

I would do that going forward, but now you have to address where you’re at…

I suspect your db image bumped up from whatever you had before to a major new version.

From the looks of it you can resolve that issue by following it’s advice (roughly speaking):

2 Likes

Thank you jtr!

Your links helped me find the solution and fix this problem. Here are the steps I used, in case someone else needs them:

docker stop nextcloud
docker exec -it nextclouddb bash
psql -U nextcloud
ALTER DATABASE nextcloud REFRESH COLLATION VERSION;
REINDEX DATABASE nextcloud;
\q
exit
docker start nextcloud

It’s important to close the nextcloud docker, as the database must not be accessed during the procedure.

2 Likes

ALTER DATABASE nextcloud REFRESH COLLATION VERSION;
REINDEX DATABASE nextcloud; - are those entered in sequence? (sorry, I am noob at this)

Hi @Max_Kra - Yes.