Minor issues with v63 update: "stepping, UNIQUE constraint failed"

I’m sending this report just in case it might be problematic for someone else (everything is working correctly for me). During the update to version v63 of Mail-in-a-Box, I received these messages while Nextcloud was updating.

Disabled incompatible app: accessibility
Disabled incompatible app: calendar
Disabled incompatible app: contacts
Disabled incompatible app: files_videoplayer

Error: stepping, UNIQUE constraint failed: oc_users_external.uid, oc_users_external.backend (19)


After the update and after making the usual adjustments for my environment, I have been able to verify that apparently everything is working without issues. I even accessed the Nextcloud installation created by Mail-in-a-Box, and the contact and calendar modules seem to still be working (although I never use those modules).

I just wanted to leave this note here in case this could pose any problems or needs to be corrected, although I must say: everything seems to be working fine.

1 Like

Same experience here:

Disabled incompatible app: bruteforcesettings
Disabled incompatible app: calendar
Disabled incompatible app: contacts
Disabled incompatible app: end_to_end_encryption
Disabled incompatible app: twofactor_totp

But my upgrade actually errors and ends:

Installing Nextcloud (contacts/calendar)...

FAILED: sudo -u www-data php8.0 /usr/local/lib/owncloud/console.php app:enable contacts
-----------------------------------------
Could not download app contacts
-----------------------------------------

Solution was to sudo su before running the script, sudoing the script alone wasn’t enough.

1 Like

For what it’s worth, I ran as root, going from MIAB v61.1 to v63:
Upgraded to Nextcloud 24.0.12 fine.
Upgrading to Nextcloud 25.0.7 I received the following:

Disabled incompatible app: accessibility
Disabled incompatible app: calendar
Disabled incompatible app: contacts
Disabled incompatible app: files_videoplayer
[…]
Error: stepping, UNIQUE constraint failed: oc_users_external.uid, oc_users_external.backend (19)

No other errors and green across the board. Everything looks to be working absolutely fine.

How about calendars and contacts ??? The error suggests that the only reason MiaB has NextCloud is broken. :frowning:

@JoshData

Has anyone opened an issue on the project’s GitHub??? If not, please do.

Hi all,

Known issue and this problem existed before.

I made the v63 upgrade, tested it many times over again and experienced this problem too, yet it has a different cause. In short: you have duplicate user entries. Caused by an older version before that.

This solution from Feb 12, 2023 worked for me:

Cheers, Michael

Yeah, looks like it’s all working absolutely fine.

I notice the same error in v64 update. I had the following messages during installation.

Installing Nextcloud (contacts/calendar)…
Nextcloud is already latest version
Error: stepping, UNIQUE constraint failed: oc_users_external.uid, oc_users_exter nal.backend (19)
Installing Z-Push (Exchange/ActiveSync server)…
Installing Mail-in-a-Box system management daemon…
Installing Munin (system monitoring)…
updated DNS: OpenDKIM configuration


Your Mail-in-a-Box is running.

All seems that works perfect (But i don’t use the nextcloud that mail-in-a-box provides).

See Error emitted after following upgrade instructions for MIAB to 60.1 · Issue #2210 · mail-in-a-box/mailinabox · GitHub for the UNIQUE constraint error.
It is normal that on upgrade apps might be disabled. The ones we care about are upgraded and enabled later in the installation process (user_external, contacts and calendar).

OK. I have more information about this error.

I follow the instructions that your link brings me and i see some errors. If I execute this command…

root@box:/home/user-data/owncloud# sqlite3 owncloud.db "select * from oc_users_external;"

I can see this information
user1@deleteddomain.org|{127.0.0.1:993/imap/ssl/novalidate-cert}|
user2@deleteddomain.org|{127.0.0.1:993/imap/ssl/novalidate-cert}|
user3@deleteddomain.net|{127.0.0.1:993/imap/ssl/novalidate-cert}|
....
user1@deleteddomain.org|127.0.0.1|
user2@deleteddomain.org|127.0.0.1|
user3@deleteddomain.net|127.0.0.1|
...
rightuser1@rightdomain.com|127.0.0.1|
rightuser2@rightdomain.com|127.0.0.1|
rightuser3@rightdomain.com|127.0.0.1|



I can see a lot of users that i had deleted previously. In first place i see something that seems certificate errors. Then i can see the some users another time (Some users are in the two zones and some users are only in the first or second zone) and then the actual users. So i run this commands:

root@box:/home/user-data/owncloud# sqlite3 owncloud.db "SELECT * FROM oc_users_external WHERE EXISTS (SELECT 1 FROM oc_users_external p2 WHERE oc_users_external.uid = p2.uid AND oc_users_external.rowid > p2.rowid);"
user1@deleteddomain.org|127.0.0.1|
user2@deleteddomain.org|127.0.0.1|
user3@deleteddomain.org|127.0.0.1|

Note that now the users only appears one time.

root@box:/home/user-data/owncloud# sqlite3 owncloud.db "DELETE FROM oc_users_external WHERE EXISTS (SELECT 1 FROM oc_users_external p2 WHERE oc_users_external.uid = p2.uid AND oc_users_external.rowid > p2.rowid);"
root@box:/home/user-data/owncloud# sqlite3 owncloud.db "select * from oc_users_external;"
user1@deleteddomain.org|{127.0.0.1:993/imap/ssl/novalidate-cert}|
user2@deleteddomain.org|{127.0.0.1:993/imap/ssl/novalidate-cert}|
user3@deleteddomain.org|{127.0.0.1:993/imap/ssl/novalidate-cert}|
...
user4@deleteddomain.org|127.0.0.1|
user5@deleteddomain.org|127.0.0.1|
user6@deleteddomain.org|127.0.0.1|
...
rightuser1@rightdomain.com|127.0.0.1|
rightuser2@rightdomain.com|127.0.0.1|
rightuser3@rightdomain.com|127.0.0.1|

Now all the users appears only one time.

But… I still see users that were deleted a lot of years ago in domains that now don’t exist. ¿Is this normal?

When administrators launch the next release of mail-in-a-box i’ll see if the upgrade errors dissapear.

Regards.

The instructions make sure a user has a single entry in the table. Also, don’t forget to do the last instruction sqlite3 owncloud.db "UPDATE oc_users_external SET backend='127.0.0.1';"

I guess the old users are not cleaned up. It will probably not hurt you. This table is used by nextcloud plugin user_external to store a display name. If a user does not exist in the imap configuration (maintained by mailinabox), it cannot login.

Looking into it a bit more, I’m pretty sure this table can be cleaned up, and its rows will be recreated when necessary. Not tested! So don’t do it unless you know what you’re doing!

Perfect. I will check if the next Mail-in-a-Box update with these changes stops displaying errors. In any case, unless I’m very wrong, this shouldn’t have occurred. @alento, it might be convenient that during the next Mail-in-a-Box update, these commands are executed automatically (from the installer itself) to solve this problem for those who still have it. Consider it.

I’m very grateful for your help, @KiekerJan . Thanks.