Long time needed, external images showing in Web-GUI Photos-App

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 30.0.6.2
  • Operating system and version (e.g., Ubuntu 24.04):
    • Debian 12 (bookworm) - 64Bit
  • Web server and version (e.g, Apache 2.4.25):
    • Apache/2.4.62
  • PHP version (e.g, 8.3):
    • 8.3.17
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Archive - native on Ubuntu System PI 5
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

I use Nextcloud more as a platform for viewing images that I make available to others.
The images are stored on a NAS.
The external storage is integrated via CIFS and is therefore available in Nextcloud as a local path.
There is a group that can then access these shares.
It all works.
Now the problem:

I can see the current photos via apps on my phone like “Nextcloud” or “Photos”, but I cannot see the current photos via the web GUI (Photos app), the most recent ones are from last Year.
I can see the current photos via the web GUI and the Memories app.

So the problem seems to be in the web GUI with the Photos app. - tried different Browsers

I executed

  • occ files:scan --all

and

  • occ preview:generate-all

no current Photos, but after this command there will be the current Photos

  • occ files:scan <User> --generate-metadata

I thought that the first two commands were enough to display the images in the Photos app.

I can’t create a cron job that covers all 3 commands, the environment is always working for hours (cron.php doesn’t cover the commands)

so

occ files:scan --all - takes some time

I can try to reduce the time with

occ preview:pre-generate

but

occ files:scan --generate-metadata needs a lot of time every run

Question

  1. am I doing something wrong?
  2. is it possible to integrate this into the maintenance window?

i reduced it with some parameters like

/occ files:scan --path="$user/files/$path" --generate-metadata
/occ preview:generate-all

but it still takes some time
During this time, these errors appear in the log

{"level":3,"time":"2025-03-19T15:16:06+00:00","remoteAddr":"","user":"--","app":"memories","method":"","url":"--","message":"Indexing exception: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction","userAgent":"--","version":"30.0.7.2","data":{"app":"memories"}}
{"level":2,"time":"2025-03-19T15:16:22+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Transaction took 990.98806500435s","userAgent":"--","version":"30.0.7.2","exception":{"Exception":"Exception","Message":"Transaction took 990.98806500435s","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/DB/ConnectionAdapter.php","line":135,"function":"commit","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Utils/Scanner.php","line":274,"function":"commit","class":"OC\\DB\\ConnectionAdapter","type":"->"},{"file":"/var/www/nextcloud/apps/files/lib/Command/Scan.php","line":153,"function":"scan","class":"OC\\Files\\Utils\\Scanner","type":"->"},{"file":"/var/www/nextcloud/apps/files/lib/Command/Scan.php","line":214,"function":"scanFiles","class":"OCA\\Files\\Command\\Scan","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":326,"function":"execute","class":"OCA\\Files\\Command\\Scan","type":"->"},{"file":"/var/www/nextcloud/core/Command/Base.php","line":161,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":1078,"function":"run","class":"OC\\Core\\Command\\Base","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":324,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":175,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/lib/private/Console/Application.php","line":183,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/console.php","line":87,"function":"run","class":"OC\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/occ","line":33,"args":["/var/www/nextcloud/console.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/DB/Connection.php","Line":838,"message":"Transaction took 990.98806500435s","exception":{},"timeSpent":990.9880650043488,"CustomMessage":"Transaction took 990.98806500435s"}}
{"level":2,"time":"2025-03-19T15:21:24+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Transaction took 302.16712713242s","userAgent":"--","version":"30.0.7.2","exception":{"Exception":"Exception","Message":"Transaction took 302.16712713242s","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/DB/ConnectionAdapter.php","line":135,"function":"commit","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Utils/Scanner.php","line":274,"function":"commit","class":"OC\\DB\\ConnectionAdapter","type":"->"},{"file":"/var/www/nextcloud/apps/files/lib/Command/Scan.php","line":153,"function":"scan","class":"OC\\Files\\Utils\\Scanner","type":"->"},{"file":"/var/www/nextcloud/apps/files/lib/Command/Scan.php","line":214,"function":"scanFiles","class":"OCA\\Files\\Command\\Scan","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":326,"function":"execute","class":"OCA\\Files\\Command\\Scan","type":"->"},{"file":"/var/www/nextcloud/core/Command/Base.php","line":161,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":1078,"function":"run","class":"OC\\Core\\Command\\Base","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":324,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":175,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/lib/private/Console/Application.php","line":183,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/console.php","line":87,"function":"run","class":"OC\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/occ","line":33,"args":["/var/www/nextcloud/console.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/DB/Connection.php","Line":838,"message":"Transaction took 302.16712713242s","exception":{},"timeSpent":302.16712713241577,"CustomMessage":"Transaction took 302.16712713242s"}}
{"level":3,"time":"2025-03-19T15:36:06+00:00","remoteAddr":"","user":"--","app":"memories","method":"","url":"--","message":"Indexing exception: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction","userAgent":"--","version":"30.0.7.2","data":{"app":"memories"}}
{"level":2,"time":"2025-03-19T15:40:21+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Transaction took 990.02078485489s","userAgent":"--","version":"30.0.7.2","exception":{"Exception":"Exception","Message":"Transaction took 990.02078485489s","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/DB/ConnectionAdapter.php","line":135,"function":"commit","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Utils/Scanner.php","line":274,"function":"commit","class":"OC\\DB\\ConnectionAdapter","type":"->"},{"file":"/var/www/nextcloud/apps/files/lib/Command/Scan.php","line":153,"function":"scan","class":"OC\\Files\\Utils\\Scanner","type":"->"},{"file":"/var/www/nextcloud/apps/files/lib/Command/Scan.php","line":214,"function":"scanFiles","class":"OCA\\Files\\Command\\Scan","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":326,"function":"execute","class":"OCA\\Files\\Command\\Scan","type":"->"},{"file":"/var/www/nextcloud/core/Command/Base.php","line":161,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":1078,"function":"run","class":"OC\\Core\\Command\\Base","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":324,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":175,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/lib/private/Console/Application.php","line":183,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/console.php","line":87,"function":"run","class":"OC\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/occ","line":33,"args":["/var/www/nextcloud/console.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/DB/Connection.php","Line":838,"message":"Transaction took 990.02078485489s","exception":{},"timeSpent":990.0207848548889,"CustomMessage":"Transaction took 990.02078485489s"}}
{"level":2,"time":"2025-03-19T15:45:28+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Transaction took 306.10775089264s","userAgent":"--","version":"30.0.7.2","exception":{"Exception":"Exception","Message":"Transaction took 306.10775089264s","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/DB/ConnectionAdapter.php","line":135,"function":"commit","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Utils/Scanner.php","line":274,"function":"commit","class":"OC\\DB\\ConnectionAdapter","type":"->"},{"file":"/var/www/nextcloud/apps/files/lib/Command/Scan.php","line":153,"function":"scan","class":"OC\\Files\\Utils\\Scanner","type":"->"},{"file":"/var/www/nextcloud/apps/files/lib/Command/Scan.php","line":214,"function":"scanFiles","class":"OCA\\Files\\Command\\Scan","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":326,"function":"execute","class":"OCA\\Files\\Command\\Scan","type":"->"},{"file":"/var/www/nextcloud/core/Command/Base.php","line":161,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":1078,"function":"run","class":"OC\\Core\\Command\\Base","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":324,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":175,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/lib/private/Console/Application.php","line":183,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/console.php","line":87,"function":"run","class":"OC\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/occ","line":33,"args":["/var/www/nextcloud/console.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/DB/Connection.php","Line":838,"message":"Transaction took 306.10775089264s","exception":{},"timeSpent":306.10775089263916,"CustomMessage":"Transaction took 306.10775089264s"}}

Is there a way to avoid this?

It’s probably because the files:scan is running during that time, and only then do these messages appear.

Since no suggestion has been received so far, I’ll suspend cron.php during the time the above commands are running.

I don’t think there are any disadvantages? The NC won’t be used during that time anyway, since it’s at night.