SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '7457-1687094389' for key 'gf_versions_uniq_index'

Hi,
I am running nextcloud using docker-compose behind nginx. After updating the installation to version 28.0.1, I keep getting the following error messages in the nextcloud logs hourly (when cron runs):

DbalException An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '7457-1687094389' for key 'gf_versions_uniq_index'

I have also been trying to install collabora (unsuccesfully), which might have something to do with this error.

Thank you in advance for helping me out.

SETUP DETAILS
Nextcloud version: 28.0.1
Operating system and version: Ubuntu 22.04.2 LTS
Apache or nginx version: nginx/1.18.0 (Ubuntu)
PHP version: 8.2.14

Is this the first time you’ve seen this error? : Yes

Steps to replicate it:

I do not know how to replicate it.

The output of your Nextcloud log in Admin > Logging:
(this is the most recent one, the logs are full of the same error every hour)

{
  "reqId": "MTIoiCqQ8JKb0i6Q04Js",
  "level": 3,
  "time": "2023-12-30T19:50:03+00:00",
  "remoteAddr": "",
  "user": "--",
  "app": "core",
  "method": "",
  "url": "--",
  "message": "Error while running background job (class: OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions, arguments: )",
  "userAgent": "--",
  "version": "28.0.1.1",
  "exception": {
    "Exception": "OC\\DB\\Exceptions\\DbalException",
    "Message": "An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 7457-1687094389 for key gf_versions_uniq_index",
    "Code": 1062,
    "Trace": [
      {
        "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
        "line": 328,
        "function": "wrap",
        "class": "OC\\DB\\Exceptions\\DbalException",
        "type": "::",
        "args": [
          [
            "Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php",
        "line": 137,
        "function": "executeStatement",
        "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/VersionsBackend.php",
        "line": 88,
        "function": "insert",
        "class": "OCP\\AppFramework\\Db\\QBMapper",
        "type": "->",
        "args": [
          [
            "OCA\\GroupFolders\\Versions\\GroupVersionEntity",
            null
          ]
        ]
      },
      {
        "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php",
        "line": 72,
        "function": "getVersionsForFile",
        "class": "OCA\\GroupFolders\\Versions\\VersionsBackend",
        "type": "->",
        "args": [
          [
            "OC\\User\\User"
          ],
          [
            "OC\\Files\\FileInfo"
          ]
        ]
      },
      {
        "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php",
        "line": 59,
        "function": "expireFolder",
        "class": "OCA\\GroupFolders\\Versions\\GroupVersionsExpireManager",
        "type": "->",
        "args": [
          [
            1,
            "Shared (Family)",
            [
              [
                "family",
                31,
                "group"
              ]
            ],
            805306368000,
            0,
            "And 1 more entries, set log level to debug to see all entries"
          ]
        ]
      },
      {
        "file": "/var/www/html/custom_apps/groupfolders/lib/BackgroundJob/ExpireGroupVersions.php",
        "line": 43,
        "function": "expireAll",
        "class": "OCA\\GroupFolders\\Versions\\GroupVersionsExpireManager",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/Job.php",
        "line": 81,
        "function": "run",
        "class": "OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions",
        "type": "->",
        "args": [
          null
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php",
        "line": 102,
        "function": "start",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->",
        "args": [
          [
            "OC\\BackgroundJob\\JobList"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php",
        "line": 92,
        "function": "start",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->",
        "args": [
          [
            "OC\\BackgroundJob\\JobList"
          ]
        ]
      },
      {
        "file": "/var/www/html/cron.php",
        "line": 152,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\TimedJob",
        "type": "->",
        "args": [
          [
            "OC\\BackgroundJob\\JobList"
          ],
          [
            "OC\\Log"
          ]
        ]
      }
    ],
    "File": "/var/www/html/lib/private/DB/Exceptions/DbalException.php",
    "Line": 71,
    "Previous": {
      "Exception": "Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException",
      "Message": "An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 7457-1687094389 for key gf_versions_uniq_index",
      "Code": 1062,
      "Trace": [
        {
          "file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
          "line": 1938,
          "function": "convert",
          "class": "Doctrine\\DBAL\\Driver\\API\\MySQL\\ExceptionConverter",
          "type": "->",
          "args": [
            [
              "Doctrine\\DBAL\\Driver\\PDO\\Exception"
            ],
            [
              "Doctrine\\DBAL\\Query"
            ]
          ]
        },
        {
          "file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
          "line": 1880,
          "function": "handleDriverException",
          "class": "Doctrine\\DBAL\\Connection",
          "type": "->",
          "args": [
            [
              "Doctrine\\DBAL\\Driver\\PDO\\Exception"
            ],
            [
              "Doctrine\\DBAL\\Query"
            ]
          ]
        },
        {
          "file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
          "line": 1208,
          "function": "convertExceptionDuringQuery",
          "class": "Doctrine\\DBAL\\Connection",
          "type": "->",
          "args": [
            [
              "Doctrine\\DBAL\\Driver\\PDO\\Exception"
            ],
            "INSERT INTO `oc_group_folders_versions` (`file_id`, `timestamp`, `size`, `mimetype`, `metadata`) VALUES(?, ?, ?, ?, ?)",
            [
              7457,
              1687094389,
              8196,
              12,
              "[]"
            ],
            [
              2,
              1,
              1,
              1,
              2
            ]
          ]
        },
        {
          "file": "/var/www/html/lib/private/DB/Connection.php",
          "line": 294,
          "function": "executeStatement",
          "class": "Doctrine\\DBAL\\Connection",
          "type": "->",
          "args": [
            "INSERT INTO `oc_group_folders_versions` (`file_id`, `timestamp`, `size`, `mimetype`, `metadata`) VALUES(?, ?, ?, ?, ?)",
            [
              7457,
              1687094389,
              8196,
              12,
              "[]"
            ],
            [
              2,
              1,
              1,
              1,
              2
            ]
          ]
        },
        {
          "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php",
          "line": 386,
          "function": "executeStatement",
          "class": "OC\\DB\\Connection",
          "type": "->",
          "args": [
            "INSERT INTO `oc_group_folders_versions` (`file_id`, `timestamp`, `size`, `mimetype`, `metadata`) VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4, :dcValue5)",
            [
              7457,
              1687094389,
              8196,
              12,
              "[]"
            ],
            [
              2,
              1,
              1,
              1,
              2
            ]
          ]
        },
        {
          "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
          "line": 280,
          "function": "execute",
          "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
          "line": 326,
          "function": "execute",
          "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php",
          "line": 137,
          "function": "executeStatement",
          "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/VersionsBackend.php",
          "line": 88,
          "function": "insert",
          "class": "OCP\\AppFramework\\Db\\QBMapper",
          "type": "->",
          "args": [
            [
              "OCA\\GroupFolders\\Versions\\GroupVersionEntity",
              null
            ]
          ]
        },
        {
          "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php",
          "line": 72,
          "function": "getVersionsForFile",
          "class": "OCA\\GroupFolders\\Versions\\VersionsBackend",
          "type": "->",
          "args": [
            [
              "OC\\User\\User"
            ],
            [
              "OC\\Files\\FileInfo"
            ]
          ]
        },
        {
          "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php",
          "line": 59,
          "function": "expireFolder",
          "class": "OCA\\GroupFolders\\Versions\\GroupVersionsExpireManager",
          "type": "->",
          "args": [
            [
              1,
              "Shared (Family)",
              [
                [
                  "family",
                  31,
                  "group"
                ]
              ],
              805306368000,
              0,
              "And 1 more entries, set log level to debug to see all entries"
            ]
          ]
        },
        {
          "file": "/var/www/html/custom_apps/groupfolders/lib/BackgroundJob/ExpireGroupVersions.php",
          "line": 43,
          "function": "expireAll",
          "class": "OCA\\GroupFolders\\Versions\\GroupVersionsExpireManager",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/html/lib/public/BackgroundJob/Job.php",
          "line": 81,
          "function": "run",
          "class": "OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions",
          "type": "->",
          "args": [
            null
          ]
        },
        {
          "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php",
          "line": 102,
          "function": "start",
          "class": "OCP\\BackgroundJob\\Job",
          "type": "->",
          "args": [
            [
              "OC\\BackgroundJob\\JobList"
            ]
          ]
        },
        {
          "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php",
          "line": 92,
          "function": "start",
          "class": "OCP\\BackgroundJob\\TimedJob",
          "type": "->",
          "args": [
            [
              "OC\\BackgroundJob\\JobList"
            ]
          ]
        },
        {
          "file": "/var/www/html/cron.php",
          "line": 152,
          "function": "execute",
          "class": "OCP\\BackgroundJob\\TimedJob",
          "type": "->",
          "args": [
            [
              "OC\\BackgroundJob\\JobList"
            ],
            [
              "OC\\Log"
            ]
          ]
        }
      ],
      "File": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php",
      "Line": 62,
      "Previous": {
        "Exception": "Doctrine\\DBAL\\Driver\\PDO\\Exception",
        "Message": "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 7457-1687094389 for key gf_versions_uniq_index",
        "Code": 1062,
        "Trace": [
          {
            "file": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php",
            "line": 132,
            "function": "new",
            "class": "Doctrine\\DBAL\\Driver\\PDO\\Exception",
            "type": "::",
            "args": [
              [
                "PDOException",
                [
                  "23000",
                  1062,
                  "Duplicate entry 7457-1687094389 for key gf_versions_uniq_index"
                ]
              ]
            ]
          },
          {
            "file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
            "line": 1202,
            "function": "execute",
            "class": "Doctrine\\DBAL\\Driver\\PDO\\Statement",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/html/lib/private/DB/Connection.php",
            "line": 294,
            "function": "executeStatement",
            "class": "Doctrine\\DBAL\\Connection",
            "type": "->",
            "args": [
              "INSERT INTO `oc_group_folders_versions` (`file_id`, `timestamp`, `size`, `mimetype`, `metadata`) VALUES(?, ?, ?, ?, ?)",
              [
                7457,
                1687094389,
                8196,
                12,
                "[]"
              ],
              [
                2,
                1,
                1,
                1,
                2
              ]
            ]
          },
          {
            "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php",
            "line": 386,
            "function": "executeStatement",
            "class": "OC\\DB\\Connection",
            "type": "->",
            "args": [
              "INSERT INTO `oc_group_folders_versions` (`file_id`, `timestamp`, `size`, `mimetype`, `metadata`) VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4, :dcValue5)",
              [
                7457,
                1687094389,
                8196,
                12,
                "[]"
              ],
              [
                2,
                1,
                1,
                1,
                2
              ]
            ]
          },
          {
            "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
            "line": 280,
            "function": "execute",
            "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
            "line": 326,
            "function": "execute",
            "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php",
            "line": 137,
            "function": "executeStatement",
            "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/VersionsBackend.php",
            "line": 88,
            "function": "insert",
            "class": "OCP\\AppFramework\\Db\\QBMapper",
            "type": "->",
            "args": [
              [
                "OCA\\GroupFolders\\Versions\\GroupVersionEntity",
                null
              ]
            ]
          },
          {
            "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php",
            "line": 72,
            "function": "getVersionsForFile",
            "class": "OCA\\GroupFolders\\Versions\\VersionsBackend",
            "type": "->",
            "args": [
              [
                "OC\\User\\User"
              ],
              [
                "OC\\Files\\FileInfo"
              ]
            ]
          },
          {
            "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php",
            "line": 59,
            "function": "expireFolder",
            "class": "OCA\\GroupFolders\\Versions\\GroupVersionsExpireManager",
            "type": "->",
            "args": [
              [
                1,
                "Shared (Family)",
                [
                  [
                    "family",
                    31,
                    "group"
                  ]
                ],
                805306368000,
                0,
                "And 1 more entries, set log level to debug to see all entries"
              ]
            ]
          },
          {
            "file": "/var/www/html/custom_apps/groupfolders/lib/BackgroundJob/ExpireGroupVersions.php",
            "line": 43,
            "function": "expireAll",
            "class": "OCA\\GroupFolders\\Versions\\GroupVersionsExpireManager",
            "type": "->",
            "args": []
          },
          {
            "file": "/var/www/html/lib/public/BackgroundJob/Job.php",
            "line": 81,
            "function": "run",
            "class": "OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions",
            "type": "->",
            "args": [
              null
            ]
          },
          {
            "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php",
            "line": 102,
            "function": "start",
            "class": "OCP\\BackgroundJob\\Job",
            "type": "->",
            "args": [
              [
                "OC\\BackgroundJob\\JobList"
              ]
            ]
          },
          {
            "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php",
            "line": 92,
            "function": "start",
            "class": "OCP\\BackgroundJob\\TimedJob",
            "type": "->",
            "args": [
              [
                "OC\\BackgroundJob\\JobList"
              ]
            ]
          },
          {
            "file": "/var/www/html/cron.php",
            "line": 152,
            "function": "execute",
            "class": "OCP\\BackgroundJob\\TimedJob",
            "type": "->",
            "args": [
              [
                "OC\\BackgroundJob\\JobList"
              ],
              [
                "OC\\Log"
              ]
            ]
          }
        ],
        "File": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php",
        "Line": 28,
        "Previous": {
          "Exception": "PDOException",
          "Message": "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 7457-1687094389 for key gf_versions_uniq_index",
          "Code": "23000",
          "Trace": [
            {
              "file": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php",
              "line": 130,
              "function": "execute",
              "class": "PDOStatement",
              "type": "->",
              "args": [
                null
              ]
            },
            {
              "file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
              "line": 1202,
              "function": "execute",
              "class": "Doctrine\\DBAL\\Driver\\PDO\\Statement",
              "type": "->",
              "args": []
            },
            {
              "file": "/var/www/html/lib/private/DB/Connection.php",
              "line": 294,
              "function": "executeStatement",
              "class": "Doctrine\\DBAL\\Connection",
              "type": "->",
              "args": [
                "INSERT INTO `oc_group_folders_versions` (`file_id`, `timestamp`, `size`, `mimetype`, `metadata`) VALUES(?, ?, ?, ?, ?)",
                [
                  7457,
                  1687094389,
                  8196,
                  12,
                  "[]"
                ],
                [
                  2,
                  1,
                  1,
                  1,
                  2
                ]
              ]
            },
            {
              "file": "/var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php",
              "line": 386,
              "function": "executeStatement",
              "class": "OC\\DB\\Connection",
              "type": "->",
              "args": [
                "INSERT INTO `oc_group_folders_versions` (`file_id`, `timestamp`, `size`, `mimetype`, `metadata`) VALUES(:dcValue1, :dcValue2, :dcValue3, :dcValue4, :dcValue5)",
                [
                  7457,
                  1687094389,
                  8196,
                  12,
                  "[]"
                ],
                [
                  2,
                  1,
                  1,
                  1,
                  2
                ]
              ]
            },
            {
              "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
              "line": 280,
              "function": "execute",
              "class": "Doctrine\\DBAL\\Query\\QueryBuilder",
              "type": "->",
              "args": []
            },
            {
              "file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
              "line": 326,
              "function": "execute",
              "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
              "type": "->",
              "args": []
            },
            {
              "file": "/var/www/html/lib/public/AppFramework/Db/QBMapper.php",
              "line": 137,
              "function": "executeStatement",
              "class": "OC\\DB\\QueryBuilder\\QueryBuilder",
              "type": "->",
              "args": []
            },
            {
              "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/VersionsBackend.php",
              "line": 88,
              "function": "insert",
              "class": "OCP\\AppFramework\\Db\\QBMapper",
              "type": "->",
              "args": [
                [
                  "OCA\\GroupFolders\\Versions\\GroupVersionEntity",
                  null
                ]
              ]
            },
            {
              "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php",
              "line": 72,
              "function": "getVersionsForFile",
              "class": "OCA\\GroupFolders\\Versions\\VersionsBackend",
              "type": "->",
              "args": [
                [
                  "OC\\User\\User"
                ],
                [
                  "OC\\Files\\FileInfo"
                ]
              ]
            },
            {
              "file": "/var/www/html/custom_apps/groupfolders/lib/Versions/GroupVersionsExpireManager.php",
              "line": 59,
              "function": "expireFolder",
              "class": "OCA\\GroupFolders\\Versions\\GroupVersionsExpireManager",
              "type": "->",
              "args": [
                [
                  1,
                  "Shared (Family)",
                  [
                    [
                      "family",
                      31,
                      "group"
                    ]
                  ],
                  805306368000,
                  0,
                  "And 1 more entries, set log level to debug to see all entries"
                ]
              ]
            },
            {
              "file": "/var/www/html/custom_apps/groupfolders/lib/BackgroundJob/ExpireGroupVersions.php",
              "line": 43,
              "function": "expireAll",
              "class": "OCA\\GroupFolders\\Versions\\GroupVersionsExpireManager",
              "type": "->",
              "args": []
            },
            {
              "file": "/var/www/html/lib/public/BackgroundJob/Job.php",
              "line": 81,
              "function": "run",
              "class": "OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions",
              "type": "->",
              "args": [
                null
              ]
            },
            {
              "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php",
              "line": 102,
              "function": "start",
              "class": "OCP\\BackgroundJob\\Job",
              "type": "->",
              "args": [
                [
                  "OC\\BackgroundJob\\JobList"
                ]
              ]
            },
            {
              "file": "/var/www/html/lib/public/BackgroundJob/TimedJob.php",
              "line": 92,
              "function": "start",
              "class": "OCP\\BackgroundJob\\TimedJob",
              "type": "->",
              "args": [
                [
                  "OC\\BackgroundJob\\JobList"
                ]
              ]
            },
            {
              "file": "/var/www/html/cron.php",
              "line": 152,
              "function": "execute",
              "class": "OCP\\BackgroundJob\\TimedJob",
              "type": "->",
              "args": [
                [
                  "OC\\BackgroundJob\\JobList"
                ],
                [
                  "OC\\Log"
                ]
              ]
            }
          ],
          "File": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php",
          "Line": 130
        }
      }
    },
    "message": "Error while running background job (class: OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions, arguments: )",
    "exception": {},
    "CustomMessage": "Error while running background job (class: OCA\\GroupFolders\\BackgroundJob\\ExpireGroupVersions, arguments: )"
  }
}

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'overwriteprotocol' => 'https',
  'mail_smtpmode' => 'smtp',
  'mail_smtphost' => 'xxxxxxx',
  'mail_smtpport' => '587',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauth' => true,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpname' => 'xxxxx@example.com',
  'mail_from_address' => 'xxxxxxx',
  'mail_domain' => 'xxxxxxx',
  'mail_smtppassword' => 'xxxxxxxxx',
  'instanceid' => 'xxxxx',
  'passwordsalt' => 'xxxxx',
  'secret' => 'xxxxx',
  'trusted_domains' => 
  array (
    0 => 'xxxxxxx.com',
  ),
'datadirectory' => '/srv/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '28.0.1.1',
  'overwrite.cli.url' => 'https://xxxxxx.com',
  'dbname' => 'db',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxxxxxxxx',
  'dbpassword' => 'xxxxxxxxxxxx',
  'installed' => true,
  'default_phone_region' => 'xx',
  'skeletondirectory' => 'core/default_files',
  'maintenance' => false,
  'loglevel' => 2,
);

The error message can be broken down as follows:

  • SQLSTATE[23000]: This is an SQL standard code indicating an integrity constraint violation. The code “23000” specifies that it is an integrity constraint violation, typically pointing to a duplicate entry or another type of integrity violation in the database.
  • Integrity constraint violation: Integrity violations occur when the integrity of relational databases, such as unique keys or foreign keys, is not maintained.
  • 1062: This is the specific error code for the integrity violation. The code “1062” stands for “Duplicate entry.” In this context, it means that an attempt was made to insert a record with a unique key value into the table that already exists.

In your example, “7457-1687094389” refers to the unique key value, where “7457” is the “file_id,”

  • You can query the database for that file_id:
    SELECT CONCAT(oc_storages.id, oc_filecache.path) AS concatenated_path FROM oc_storages INNER JOIN oc_filecache ON oc_storages.numeric_id = oc_filecache.storage WHERE oc_filecache.fileid = 7457;
    

… and “1687094389” is the “timestamp” in unix-time (human readable: 2023-06-18 15:19:49).
The error code “1062” signals that this key value already exists in the database table and cannot be inserted again.


Once you know what file is affected, you can try to remove one of them. My observation is, that it is mostly a file in the trashbin, and in the versions folder.

Here an example:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '8826002-1702996424' for key 'gf_versions_uniq_index'

So I checked fileid 8826002:

MariaDB [nextcloud]> SELECT CONCAT(oc_storages.id, oc_filecache.path) AS concatenated_path FROM oc_storages INNER JOIN oc_filecache ON oc_storages.numeric_id = oc_filecache.storage WHERE oc_filecache.fileid = 8826002;
+-------------------------------------------------------------------------+
| concatenated_path                                                       |
+-------------------------------------------------------------------------+
| local::/nc/dat/data/__groupfolders/trash/9/Spring_83_Em.mp3.d1704291095 |
+-------------------------------------------------------------------------+
1 row in set (0,002 sec)

then I emptied trashbin for groupfolder 9:

sudo -u www-data php -f /var/www/nextcloud/occ groupfolders:trashbin:cleanup 9
Are you sure you want to empty the trashbin of your group folder with id 9, this can not be undone (y/N).y

then:

sudo -u www-data php -f /var/www/nextcloud/occ groupfolders:expire

That procedure did fix it for me.


I hope this helps!

Much luck,
ernolf

Thank you for your help,

My apologies for the late reply.

I have tried the solution you proposed, but the first query did not identify any duplicate entries so I feel like there might be a different issue.

However, when looking at the concatenated filepath it seems to point to a DS_Store file in the trashbin. To be sure I have just emptied the trashbin in the hope that this fixes it.
I will give an update if this fixes the warning.

It did not resolve the issue unfortunately.

Same here with nextcloud 28.0.1 on docker with linuxserver.io image behind an nginx reverse proxy and also collabora in a seperate docker instance. Seems an issue with the group folders app? Br Thomas

Take a look at Backends provided no user object / Duplicate entry for key 'gf_versions_uniq_index' · Issue #2559 · nextcloud/groupfolders · GitHub

I got this error as well and it was pointing to a file in trashbin too.

How did you empty the trash? With occ groupfolders:trashbin:cleanup <folder_id> or from within the web interface?

I first emptied the trashbin with occ command, then did I run occ groupfolders:expire and everything was fixed.

Much luck,
ernolf

I did it using occ trashbin:cleanup —all

I wasn’t aware there was a special command for the group folders.

That does not affect the groupfolder trash, so that could not solve it of course :wink:

ernolf

1 Like