Error 1062 Duplicate entry 'mail_messages_mb_id_uid_uidx'

Today, I’ve upgraded my NC instance to version 29.0.2.
Upon performing the occ db: add-missing-indices step, I’ve got the following error message:

In ExceptionConverter.php line 62:

An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘14-65501’ for key ‘mail_messages_mb_id_uid_uidx’

In Exception.php line 28:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘14-65501’ for key ‘mail_messages_mb_id_uid_uidx’

In Connection.php line 71:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘14-65501’ for key ‘mail_messages_mb_id_uid_uidx’

db:add-missing-indices [–dry-run]

What could I do to solve this issue? The mail app seems to be working fine. FYI, I use this instance only for me personally so if it could be solved by wiping a db table this would be fine for me.

1 Like

Same Problem. Could you solve the issue?

Hi,

we’ve added a repair routine for mail to prepare the database for the new index: fix: add repair job to deleted duplicated cached messages by st3iny · Pull Request #9765 · nextcloud/mail · GitHub

Update your mail app to 3.7.2 and try again.

Hi, I have the same problem since the migration to Nextcloud 29. How can it be solved ?

sudo -u nextcloud php /var/www/nextcloud/occ db:add-missing-indices
Adding additional mail_messages_mb_id_uid_uidx index to the oc_mail_messages table, this can take some time...

In ExceptionConverter.php line 62:
An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '16-87' for key 'mail_messages_mb_id_uid_uidx'

In Exception.php line 28:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '16-87' for key 'mail_messages_mb_id_uid_uidx'

In Connection.php line 71:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '16-87' for key 'mail_messages_mb_id_uid_uidx'

Nextcloud 29.0.4
Mail app 3.7.5