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.