Database errors in postgresql log (duplicate key value)

Nextcloud version: 22.2.0
Operating system and version: debian buster
Apache or nginx version: Apache 2.4.38
PHP version (eg, 7.4): 7.3.29

Dear all,

I have plenty of these in my postgresql log file:

2021-10-18 10:43:44.126 CEST [31017] nextcloud@nextcloud ERROR:  duplicate key value violates unique constraint "oc_filecache_extended_pkey"
2021-10-18 10:43:44.126 CEST [31017] nextcloud@nextcloud DETAIL:  Key (fileid)=(300863) already exists.
2021-10-18 10:43:44.126 CEST [31017] nextcloud@nextcloud STATEMENT:  INSERT INTO "oc_filecache_extended" ("fileid", "upload_time") VALUES($1, $2)

Nothing related can be found in the nextcloud logs…

Thanks for any clues,

Christian

1 Like

I’ve got quite a few of these errors too. I’m on gentoo, nextcloud-22.2.0, php-7.4, nginx-1.20. This started at least a few months ago on nextcloud-21.., or maybe earlier.

I see this reliably when I edit a file. When I create say test.txt, there is no error. But the error appears on each edit.

I have a similar problem, however postgres exits and will not start. This is the log entry from AIO dashboard;

Setting postgres values...
chmod: /var/run/postgresql: Operation not permitted

PostgreSQL Database directory appears to contain a database; Skipping initialization

2024-02-11 20:04:15.468 PST [14] LOG:  starting PostgreSQL 15.5 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014, 64-bit
2024-02-11 20:04:15.468 PST [14] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2024-02-11 20:04:15.468 PST [14] LOG:  listening on IPv6 address "::", port 5432
2024-02-11 20:04:15.471 PST [14] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2024-02-11 20:04:15.478 PST [24] LOG:  database system was shut down at 2024-02-11 20:01:16 PST
2024-02-11 20:04:15.498 PST [14] LOG:  database system is ready to accept connections
2024-02-12 12:13:03.243 PST [38780] ERROR:  duplicate key value violates unique constraint "oc_filecache_extended_pkey"
2024-02-12 12:13:03.243 PST [38780] DETAIL:  Key (fileid)=(114141) already exists.
2024-02-12 12:13:03.243 PST [38780] STATEMENT:  INSERT INTO "oc_filecache_extended" ("fileid", "upload_time") VALUES($1, $2)
2024-02-12 12:13:03.275 PST [38779] ERROR:  duplicate key value violates unique constraint "oc_filecache_extended_pkey"
2024-02-12 12:13:03.275 PST [38779] DETAIL:  Key (fileid)=(114142) already exists.
2024-02-12 12:13:03.275 PST [38779] STATEMENT:  INSERT INTO "oc_filecache_extended" ("fileid", "upload_time") VALUES($1, $2)
2024-02-12 13:18:48.342 PST [42560] ERROR:  duplicate key value violates unique constraint "oc_filecache_extended_pkey"
2024-02-12 13:18:48.342 PST [42560] DETAIL:  Key (fileid)=(114141) already exists.
2024-02-12 13:18:48.342 PST [42560] STATEMENT:  INSERT INTO "oc_filecache_extended" ("fileid", "upload_time") VALUES($1, $2)
++ rm -f /mnt/data/database-dump.sql.temp
++ touch /mnt/data/export.failed
++ pg_dump --username nextcloud nextcloud_database
++ rm -f /mnt/data/database-dump.sql
++ mv /mnt/data/database-dump.sql.temp /mnt/data/database-dump.sql
++ pg_ctl stop -m fast
2024-02-12 14:56:03.528 PST [14] LOG:  received fast shutdown request
2024-02-12 14:56:03.530 PST [14] LOG:  aborting any active transactions
2024-02-12 14:56:03.530 PST [46639] FATAL:  terminating connection due to administrator command
2024-02-12 14:56:03.535 PST [14] LOG:  background worker "logical replication launcher" (PID 27) exited with exit code 1
2024-02-12 14:56:03.538 PST [22] LOG:  shutting down
2024-02-12 14:56:03.630 PST [14] LOG:  database system is shut down
waiting for server to shut down.... done
server stopped
++ rm /mnt/data/export.failed
Database dump successful!
++ echo 'Database dump successful!'

x

How can I fix this and start my database? I don’t even see a docker container named “Database”