Unique DB key violations for table `oc_filecache` and keys `fs_storage_path_hash` and `files_versions_uniq_index`

Since some time, I have been seeing the following two PostgreSQL errors:

[34236] nextcloud@nextcloud ERROR: duplicate key value violates unique constraint "fs_storage_path_hash"
[34236] nextcloud@nextcloud DETAIL: Key (storage, path_hash)=(2, 45bedc94f500b9165da503f46549f339) already exists. [34236] nextcloud@nextcloud_famna 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)

and/or

[2445] nextcloud@nextcloud ERROR: duplicate key value violates unique constraint "files_versions_uniq_index"
[2445] nextcloud@nextcloud DETAIL: Key (file_id, "timestamp")=(411463, 1214515680) already exists. [2445] nextcloud@nextcloud_famna STATEMENT: UPDATE "oc_files_versions" SET "timestamp" = $1 WHERE "id" = $2

This seems to be accompanied by the following Nextcloud error

{
	"reqId": "3MhWHXg0ocLBDT9mkEDc",
	"level": 3,
	"time": "2024-02-29T19:38:38+00:00",
	"remoteAddr": "2003:e0:d73d:8000:95aa:7cb4:e390:aa9a",
	"user": "sophie.nagel",
	"app": "no app in context",
	"method": "PUT",
	"url": "/remote.php/dav/uploads/sophie.nagel/3805586494/00016",
	"message": "Erwartete Dateigröße von 29175408 Bytes, aber 23805952 Bytes gelesen (vom Nextcloud-Client) und geschrieben (in den Nextcloud-Speicher). Dies kann entweder ein Netzwerkproblem auf der sendenden Seite oder ein Problem beim Schreiben in den Speicher auf der Serverseite sein.",
	"userAgent": "Mozilla/5.0 (Windows) mirall/3.12.0stable-Win64 (build 20240213) (Nextcloud, windows-10.0.19045 ClientArchitecture: x86_64 OsArchitecture: x86_64)",
	"version": "28.0.2.5",
	"exception": {
		"Exception": "Sabre\\DAV\\Exception\\BadRequest",
		"Message": "Erwartete Dateigröße von 29175408 Bytes, aber 23805952 Bytes gelesen (vom Nextcloud-Client) und geschrieben (in den Nextcloud-Speicher). Dies kann entweder ein Netzwerkproblem auf der sendenden Seite oder ein Problem beim Schreiben in den Speicher auf der Serverseite sein.",
		"Code": 0,
		"Trace": [{
			"file": "/var/www/famna.de/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php",
			"line": 148,
			"function": "put",
			"class": "OCA\\DAV\\Connector\\Sabre\\File",
			"type": "->"
		}, {
			"file": "/var/www/famna.de/nextcloud/apps/dav/lib/Upload/UploadFolder.php",
			"line": 51,
			"function": "createFile",
			"class": "OCA\\DAV\\Connector\\Sabre\\Directory",
			"type": "->",
			"args": ["*** sensitive parameters replaced ***"]
		}, {
			"file": "/var/www/famna.de/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
			"line": 1098,
			"function": "createFile",
			"class": "OCA\\DAV\\Upload\\UploadFolder",
			"type": "->",
			"args": ["*** sensitive parameters replaced ***"]
		}, {
			"file": "/var/www/famna.de/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
			"line": 504,
			"function": "createFile",
			"class": "Sabre\\DAV\\Server",
			"type": "->",
			"args": ["*** sensitive parameters replaced ***"]
		}, {
			"file": "/var/www/famna.de/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
			"line": 89,
			"function": "httpPut",
			"class": "Sabre\\DAV\\CorePlugin",
			"type": "->"
		},{
			"file": "/var/www/famna.de/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
			"line": 472,
			"function": "emit",
			"class": "Sabre\\DAV\\Server",
			"type":"->"
		},{
			"file": "/var/www/famna.de/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
			"line": 253,
			"function": "invokeMethod",
			"class": "Sabre\\DAV\\Server",
			"type": "->"
		},{
			"file": "/var/www/famna.de/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
			"line": 321,
			"function": "start",
			"class": "Sabre\\DAV\\Server",
			"type": "->"
		},{
			"file": "/var/www/famna.de/nextcloud/apps/dav/lib/Server.php",
			"line": 370,
			"function": "exec",
			"class": "Sabre\\DAV\\Server",
			"type": "->"
		},{
			"file": "/var/www/famna.de/nextcloud/apps/dav/appinfo/v2/remote.php",
			"line": 35,
			"function": "exec",
			"class": "OCA\\DAV\\Server",
			"type": "->"
		},{
			"file": "/var/www/famna.de/nextcloud/remote.php",
			"line": 172,
			"args": ["/var/www/famna.de/nextcloud/apps/dav/appinfo/v2/remote.php"],
			"function": "require_once"
		}],
		"File": "/var/www/famna.de/nextcloud/apps/dav/lib/Connector/Sabre/File.php",
		"Line": 301,
		"message": "Erwartete Dateigröße von 29175408 Bytes, aber 23805952 Bytes gelesen (vom Nextcloud-Client) und geschrieben (in den Nextcloud-Speicher). Dies kann entweder ein Netzwerkproblem auf der sendenden Seite oder ein Problem beim Schreiben in den Speicher auf der Serverseite sein.",
		"exception":[],
		"CustomMessage": "Erwartete Dateigröße von 29175408 Bytes, aber 23805952 Bytes gelesen (vom Nextcloud-Client) und geschrieben (in den Nextcloud-Speicher). Dies kann entweder ein Netzwerkproblem auf der sendenden Seite oder ein Problem beim Schreiben in den Speicher auf der Serverseite sein."
	},
	"id": "65e4533be33ce"
}

What may cause these error messages and how can I fix it?

(Note, I am not sure whether these three error messages are related, but I assume so.)

The Nextcloud error message suggests that one of the possible reasons might be a problem with writing the file to storage. I doubt that as I have plenty of free storage

server ~ # LC_ALL=C df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       2.0T  337G  1.7T  17% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G  1.1M   16G   1% /dev/shm
tmpfs           6.3G  576K  6.3G   1% /run
efivarfs        256K   64K  188K  26% /sys/firmware/efi/efivars
/dev/vda1      1022M   15M 1008M   2% /boot
tmpfs            16G  800K   16G   1% /tmp
tmpfs           3.2G  4.0K  3.2G   1% /run/user/0