jonaswinkler / paperless-ng

A supercharged version of paperless: scan, index and archive all your physical documents
https://paperless-ng.readthedocs.io/en/latest/
GNU General Public License v3.0
5.37k stars 358 forks source link

[BUG] Latest Postgres version throws DB incompatability error #1361

Open rYR79435 opened 2 years ago

rYR79435 commented 2 years ago

Describe the bug Today I noticed I couldn't reach my Paperless instance anymore. Logs below.

My workaround is to specify version 13 of Postgres in the docker-compose file.

To Reproduce I'm not sure when this issue first arose, as my containers update automatically and I haven't used Paperless in a while (>2 weeks).

Webserver logs

paperless_db |
paperless_db | PostgreSQL Database directory appears to contain a database; Skipping initialization
paperless_db |
paperless_db | 2021-10-03 16:29:58.402 UTC [1] FATAL:  database files are incompatible with server
paperless_db | 2021-10-03 16:29:58.402 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0 (Debian 14.0-1.pgdg110+1).
paperless_db |
paperless_db | PostgreSQL Database directory appears to contain a database; Skipping initialization
paperless_db |
paperless_db | 2021-10-03 16:30:02.191 UTC [1] FATAL:  database files are incompatible with server
paperless_db | 2021-10-03 16:30:02.191 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0 (Debian 14.0-1.pgdg110+1).
paperless_db exited with code 1
paperless_db | 2021-10-03 16:30:03.666 UTC [1] FATAL:  database files are incompatible with server
paperless_db | 2021-10-03 16:30:03.666 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0 (Debian 14.0-1.pgdg110+1).
paperless_db exited with code 1
paperless_db |
paperless_db | PostgreSQL Database directory appears to contain a database; Skipping initialization
paperless_db |
paperless_db | 2021-10-03 16:30:05.893 UTC [1] FATAL:  database files are incompatible with server
paperless_db | 2021-10-03 16:30:05.893 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0 (Debian 14.0-1.pgdg110+1).
paperless_db exited with code 1
paperless_db |
paperless_db | PostgreSQL Database directory appears to contain a database; Skipping initialization
paperless_db |
paperless_db | 2021-10-03 16:30:09.742 UTC [1] FATAL:  database files are incompatible with server
paperless_db | 2021-10-03 16:30:09.742 UTC [1] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0 (Debian 14.0-1.pgdg110+1).

The logs go on for quite a bit, but are repeating.

Relevant information

TobenderZephyr commented 2 years ago

This seems to be an issue with postgres itself. It looks like it doesn't migrate data between major versions automatically. There are a lot of How-Tos online for data migration which all require working backups of the database.

Since this is the database container reporting errors and not paperless-ng, I doubt this issue belongs here.

Please have a look at https://betterprogramming.pub/how-to-upgrade-your-postgresql-version-using-docker-d1e81dbbbdf9

cerealconyogurt commented 2 years ago

As far as I know this is no really a production issue but a migration requirement since it is a major release, so it requires some effort to upgrade if you want to use the latest version. In short; the DB was created by an earlier version, then the data is incompatible with the new version.

I managed to upgrade the DB of another service following these instructions: how to upgrade your postgresql. The same link that @TobenderZephyr commented in his message.

I did some changes to this process, but it worked fine.

My concern is more related to the paperless-ng ecosystem rather than to upgrade the postgresql service; does paperless-ng work fine with the new postgresql 14 version?

stepanov1975 commented 2 years ago

Why paperless container doesn't have all the needed packages inside the container, and instead relates on external? They may be updated at any time and became incompatible or just break the system. When you store all your documents inside a database like paperless you are at least expecting to be able not to lose ability to access them because the update of some package

TobenderZephyr commented 2 years ago

That is the whole point of having containers. The maintainer should not rely on updating containers if there were changes to other applications where they have no control. That's why using pgsql is entirely optional according to the Documentation.

Adding every possible 3rd party application to the container increases not just image size but also startup time! Also it would not be able to scale horizontally.

Please have a look at how Microservices are designed and why.