[Bug]: ERROR: duplicate key value violates unique constraint "fs_storage_path_hash"
Open
Nobody has claimed this yet.
0. Needs triage
27-feedback
bug
feature: database
feature: filesystem
needs review
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
Using AIO, with 27.1.0.7
Seeing:
2023-11-07 08:03:46.639 UTC [20963] ERROR: duplicate key value violates unique constraint "fs_storage_path_hash"
2023-11-07 08:03:46.639 UTC [20963] DETAIL: Key (storage, path_hash)=(3, c3d74eff1486eadc1589bf4c7f3d3c36) already exists.
2023-11-07 08:03:46.639 UTC [20963] STATEMENT: INSERT INTO "oc_filecache" ("mimepart", "mimetype", "mtime", "size", "etag", "storage_mtime", "permissions", "name", "parent", "checksum", "path_hash", "path", "storage") VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
2023-11-07 08:03:46.642 UTC [20963] ERROR: duplicate key value violates unique constraint "fs_storage_path_hash"
2023-11-07 08:03:46.642 UTC [20963] DETAIL: Key (storage, path_hash)=(3, 946a8b60665758d00a25d56c30db6f09) already exists.
2023-11-07 08:03:46.642 UTC [20963] STATEMENT: INSERT INTO "oc_filecache" ("mimepart", "mimetype", "mtime", "size", "etag", "storage_mtime", "permissions", "name", "parent", "checksum", "path_hash", "path", "storage") VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
2023-11-07 08:03:46.645 UTC [20963] ERROR: duplicate key value violates unique constraint "fs_storage_path_hash"
2023-11-07 08:03:46.645 UTC [20963] DETAIL: Key (storage, path_hash)=(3, 971bc299fe96732c655262821634af17) already exists.
2023-11-07 08:03:46.645 UTC [20963] STATEMENT: INSERT INTO "oc_filecache" ("mimepart", "mimetype", "mtime", "size", "etag", "storage_mtime", "permissions", "name", "parent", "checksum", "path_hash", "path", "storage") VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
2023-11-07 08:03:46.648 UTC [20963] ERROR: duplicate key value violates unique constraint "fs_storage_path_hash"
2023-11-07 08:03:46.648 UTC [20963] DETAIL: Key (storage, path_hash)=(3, 879cbeb279c9a99ac9e8e7370b8d2cc7) already exists.
2023-11-07 08:03:46.648 UTC [20963] STATEMENT: INSERT INTO "oc_filecache" ("mimepart", "mimetype", "mtime", "size", "etag", "storage_mtime", "permissions", "name", "parent", "checksum", "path_hash", "path", "storage") VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
2023-11-07 08:03:46.650 UTC [20963] ERROR: duplicate key value violates unique constraint "fs_storage_path_hash"
2023-11-07 08:03:46.650 UTC [20963] DETAIL: Key (storage, path_hash)=(3, 4a0420a8cad471bac8f24c6d58bab16d) already exists.
2023-11-07 08:03:46.650 UTC [20963] STATEMENT: INSERT INTO "oc_filecache" ("mimepart", "mimetype", "mtime", "size", "etag", "storage_mtime", "permissions", "name", "parent", "checksum", "path_hash", "path", "storage") VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
2023-11-07 08:03:46.654 UTC [20963] ERROR: duplicate key value violates unique constraint "fs_storage_path_hash"
2023-11-07 08:03:46.654 UTC [20963] DETAIL: Key (storage, path_hash)=(3, 903b9080f3f3a897c56ed063347b143c) already exists.
2023-11-07 08:03:46.654 UTC [20963] STATEMENT: INSERT INTO "oc_filecache" ("mimepart", "mimetype", "mtime", "size", "etag", "storage_mtime", "permissions", "name", "parent", "checksum", "path_hash", "path", "storage") VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
Steps to reproduce
- just using NC
Expected behavior
No errors
Installation method
None
Nextcloud Server version
27
Operating system
Debian/Ubuntu
PHP engine version
None
Web server
None
Database engine version
None
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
No response
List of activated Apps
No response
Nextcloud Signing status
No response
Nextcloud Logs
No response
Additional info
Very little info possible.
If you need anything, please write :)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the duplicate-key errors with the reported AIO and Nextcloud 27.1 setup, using the provided PostgreSQL statements and the oc_filecache table as the entry point. Trace how repeated inserts produce the fs_storage_path_hash violation. Done means the reported operation completes without these duplicate-key errors and the behavior is covered by a regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100