Nextcloud update failed - database is locked

I’ve been having problems with Nextcloud recently, with the new 3.0 client for windows not working at all (not sure if the server has something to do with it)
Just now I tried updating MIAB from v0.47 to v0.48.

Everything worked except for the Nextcloud step:

Updating system packages...
Installing system packages...
Initializing system random number generator...
Firewall is active and enabled on system startup
Installing nsd (DNS server)...
Installing Postfix (SMTP server)...
Installing Dovecot (IMAP server)...
Installing OpenDKIM/OpenDMARC...
Installing SpamAssassin...
bayes: synced databases from journal in 1 seconds: 372 unique entries (604 total entries)
Installing Nginx (web server)...
Installing Roundcube (webmail)...
Installing Nextcloud (contacts/calendar)...

FAILED: sudo -u www-data php /usr/local/lib/owncloud/console.php app:enable user_external
-----------------------------------------
An exception occurred while executing 'UPDATE "oc_appconfig" SET "configvalue" = ? WHERE ("appid" = ?) AND ("configkey" = ?) AND ("configvalue" <> ?)' with params ["0.10.0", "user_external", "installed_version", "0.10.0"]:
SQLSTATE[HY000]: General error: 5 database is locked
-----------------------------------------

Bumping this topic as I just encountered this same error while upgrading MIAB from v76 to v78.

if you run the command to look at your version:
cat /home/user-data/owncloud/config.php

what is the ‘version’ property?

What happens if you retry the upgrade?

On SQLite, “database is locked” usually means another process still has the Nextcloud DB open during the upgrade. Check for running Nextcloud cron/occ jobs or PHP workers, stop them (temporarily stopping php-fpm/nginx is one way), then rerun the Mail-in-a-Box upgrade. If it still fails, make a backup and look for a stale journal/lock file before retrying.