Log is filling up with warnings since upgrade from 28.0.7 to 29.0.3

Nextcloud version (eg, 29.0.5): 29.0.3
Operating system and version (eg, Ubuntu 24.04): Debian 12
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.59 (Debian)
PHP version (eg, 8.3): 8.2.20

The issue you are facing:
Since upgradeing from Nextcloud 28.0.7 to Nextcloud 29.0.3 the log is filled with these warnings:
DbalException An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘277179’ for key ‘files_meta_fileid’
issue while saveMetadata

Is this the first time you’ve seen this error? (Y/N):Y

Steps to replicate it:

  1. Log into Nextcloud
  2. Goto Adminstration-Logging

The output of your Nextcloud log in Admin > Logging:

 DbalException An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '277179' for key 'files_meta_fileid'
issue while saveMetadata 

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '************',
  'passwordsalt' => '******************************',
  'secret' => '************************************************',
  'trusted_domains' =>
  array (
    0 => '***************',
    1 => '******************',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'overwrite.cli.url' => 'https://***********************************************************************************',
  'dbtype' => 'mysql',
  'version' => '29.0.3.4',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',   
  'dbuser' => 'nextcloud',
  'dbpassword' => '*************************',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 0,
  'mail_smtpmode' => 'smtp',  
  'mail_from_address' => 'admin',
  'mail_domain' => '**********', 
  'mail_smtphost' => '************',
  'mail_smtpport' => '465',   
  'mail_sendmailmode' => 'smtp',
  'mysql.utf8mb4' => true,
  'default_phone_region' => 'DE',
  'check_for_working_wellknown_setup' => false,
  'mail_smtpsecure' => 'ssl', 
  'enable_previews' => true,  
  'preview_ffmpeg_path' => '/usr/bin/ffmpeg',
  'preview_max_x' => 16384,
  'preview_max_y' => 16384,   
  'preview_max_filesize_image' => 50,
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\TXT',  
    1 => 'OC\\Preview\\Movie',
    2 => 'OC\\Preview\\MarkDown',
    3 => 'OC\\Preview\\OpenDocument',
    4 => 'OC\\Preview\\PDF',  
    5 => 'OC\\Preview\\PNG',  
    6 => 'OC\\Preview\\JPEG', 
    7 => 'OC\\Preview\\GIF',  
    8 => 'OC\\Preview\\MP4',  
  ),
  'maintenance_window_start' => 5,
);

The output of your Apache/nginx/system log in /var/log/____:

PASTE HERE

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

DbalException An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '277179' for key 'files_meta_fileid'
issue while saveMetadata 

This issue has arisen because a unique index on the file_id column, named files_meta_fileid, was added to the oc_files_metadata table during this database migration:


These would be the steps i would try to solve the issue:

  1. First, identify the duplicate file_id values in the oc_files_metadata table:
SELECT file_id, COUNT(*) FROM oc_files_metadata GROUP BY file_id HAVING COUNT(*) > 1;

This query will list all file_id values that appear more than once in the oc_files_metadata table.


  1. Once you have identified the duplicate file_id values, review the specific entries:
SELECT * FROM oc_files_metadata WHERE file_id = 277179;  -- Replace 277179 with one of the duplicate file_id values

  1. After reviewing, decide which entries to keep and delete the duplicates. For example, to delete one of the duplicates:
DELETE FROM oc_files_metadata WHERE file_id = 277179 LIMIT 1;  -- Replace 277179 with one of the duplicate file_id values

Repeat this step for each duplicate file_id value.


  1. After deleting the duplicate entries, verify that all duplicates have been removed:
SELECT file_id, COUNT(*) FROM oc_files_metadata GROUP BY file_id HAVING COUNT(*) > 1;

No guarantee, it is a shot from the hip, so be carefull


Much and good luck,
ernolf

2 Likes

Thanks for your detailed reply. I do not dare to manually change the nextcloud databases. I hope that this will be fixed by a future update.

Can you post the entire raw log entry containing the full exception?

Without context I’m afraid no one can do anything. :slight_smile:

Just downloaded nextcloud.log and the log entries

DbalException An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘277179’ for key ‘files_meta_fileid’
issue while saveMetadata

are not there anymore.
I have the impression that some job fixed this in the meantime.

Thanks for your help.