Occasionally failed to connect to database and crash

I used owncloud up to 9 on debian 8 from years with no problem. To upgrade I made a fresh installation of debian 9 initially with owncloud X and finally with nextcloud. All works but I have the same occasional problem on both software when I upload files from the client application. Sometimes the system works for hours, other times the system works for seconds before to crash. Attention: I use a local host storage to write the users data (shared by the virtualbox host with nexcloud machine- solution used successfully for years in owncloud9).

Nextcloud version _12.0.5:
Debian 9.3 on virtualbox 5.2.6 r120293 (Qt5.7.1)
Apache/2.4.25 (Debian)
PHP 7.0.27-0+deb9u1 (cli) (built: Jan 5 2018 13:51:52) ( NTS )
mysql Ver 15.1 Distrib 10.1.26-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

PHP Modules:
apc
apcu
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
intl
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

apache2 log: AND MY PROBLEM I think:
PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:61\nStack trace:\n#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()\n#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()\n#2 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()\n#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()\n#4 /var/www/nextcloud/lib/private/DB/Connection.php(148): Doctrine\DBAL\Connection->setTransactionIsolation(2)\n#5 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Obj in /var/www/nextcloud/lib/private/DB/Connection.php on line 61
-----> for this the system crash.
I have also the problem 2:
[Wed Jan 24 21:23:50.734750 2018] [core:notice] [pid 753] AH00052: child pid 1390 exit signal Segmentation fault (11)
[Wed Jan 24 21:23:50.734868 2018] [mpm_prefork:notice] [pid 753] AH00169: caught SIGTERM, shutting down
[Wed Jan 24 21:45:52.847595 2018] [mpm_prefork:notice] [pid 3095] AH00163: Apache/2.4.25 (Debian) OpenSSL/1.0.2l configured – resuming normal operations
[Wed Jan 24 21:45:52.847685 2018] [core:notice] [pid 3095] AH00094: Command line: ‘/usr/sbin/apache2’
[Wed Jan 24 22:04:47.074877 2018] [mpm_prefork:notice] [pid 736] AH00163: Apache/2.4.25 (Debian) OpenSSL/1.0.2l configured – resuming normal operations
[Wed Jan 24 22:04:47.083217 2018] [core:notice] [pid 736] AH00094: Command line: ‘/usr/sbin/apache2’

Not see this problem in the nextcloud admin log:
Debug OC\Files\Cache\Scanner !!! Path ‘BACKUP/GIORGIO_BACKUP/Documents/AA - BACKUP/back-up siti web/adwords pubblicità/backup_site/backup/sito1/wpcontent/themes/redbusiness/fancybox/fancy_shadow_w.png’ is not accessible or present !!!
2018-01-24T21:50:53+0200

The nextcloud config.php:
?php
$CONFIG = array (
‘instanceid’ => ‘ocw1kq5i1ulv’,
‘passwordsalt’ => ‘xxxxxxxxx’,
‘secret’ => ‘xxxxxxx’,
‘trusted_domains’ =>
array (
0 => ‘xxxx’,
1 => ‘xxxxx’,
2 => ‘xxxxx’,
3 => ‘xxxx’,
4 => ‘xxxxx’,
),
‘datadirectory’ => ‘/media/CLOUD-DATA/nextcloud’,
‘overwrite.cli.url’ => ‘https://192.168.3.11/nextcloud’,
‘dbtype’ => ‘mysql’,
‘version’ => ‘12.0.5.3’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘localhost’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘dbuser’ => ‘oc_pgbuz1’,
‘dbpassword’ => ‘xxxxxxx’,
‘logtimezone’ => ‘UTC’,
‘installed’ => true,
‘memcache.local’ => ‘\OC\Memcache\APCu’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ =>
array (
‘host’ => ‘localhost’,
‘port’ => 6379,
),
‘loglevel’ => 0,
‘maintenance’ => false,
‘theme’ => ‘’,
‘mail_smtpmode’ => ‘smtp’,
‘mail_smtpauthtype’ => ‘LOGIN’,
‘mail_from_address’ => ‘admin’,

As workload I will have 4 users that sync with the client application about 70GB each with thousands of little files… actually I’m testing with one.

Thank you so much who will help

No one like help me? During the upload from nexcloud client, the nextcloud virtual machine crash completely and send to 100% one of the main cpu of the host. Nextcloud server need to restart

see here:
BEFORE CRASH

AFTER CRASH:

after crash cannot do nothing on the nexcloud server up to restart.