Slow nextcloud 14.0.4 error scanning for files on external storage

[/details]

Nextcloud version (eg, 12.0.2): 14.0.4
Operating system and version (eg, Ubuntu 18.04):
Apache
PHP version (eg, 7.2): 7.2

The issue you are facing:
The nextcloud is very slow even though it does not lack on hardware resources with 16G ram and multi-core CPU. The portal loads files slow. When I tried to do a full OCC scan to index all files, I get an error.
#17 /var/www/nextcloud/3rdparty/symfony/console/Application.php(946): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #18 /var/www/nextcloud/3rdparty/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #19 /var/www/nextcloud/3rdparty/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #20 /var/www/nextcloud/lib/private/Console/Application.php(213): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #21 /var/www/nextcloud/console.php(96): OC\Console\Application->run() #22 /var/www/nextcloud/occ(11): require_once(’/var/www/nextcl…’) #23 {main}

I had the same setup with Snap image however have not encountered such issues before. I had trouble with snap crashing and server not responding upon large file uploads, dumped it for bare bone server install, however the performance of new server still low. The PHPwas configures with max memory of 16G.
Is this the first time you’ve seen this error? (Y/N):
Y

Steps to replicate it:

  1. Fresh install of 14.0.4
  2. PHP 7.2
  3. External Server pointing to Local storage which is mounted as CIFS.

The output of your Nextcloud log in Admin > Logging:

No Logs

The output of your config.php file in /var/www/nextcloud

Standard Config

The output of your Apache/nginx/system log in /var/log/____:
``
Error logs show SSL errors, some other errors encountered listed below:
AH00169: caught SIGTERM, shutting down
server certificate does NOT include an ID which matches the server name
AH00051: child pid 44454 exit signal Segmentation fault (11), possible coredump in /etc/apache2
Protocol negotiation failed: NT_STATUS_CONNECTION_RESET
mkdir failed on directory /var/run/samba/msg.lock: Permission denied

Edit: This issue was resolved by installing a stand-alone install without snap by utilizing external storage and directly mounding through SMB mount rather than doing a local share then the scan of files succeeded. With snap not supporting SMB client and issues with Local folder mount, best was to do a bare metal install.