FastCGI sent in stderr: "PHP message: PHP Fatal error: Maximum execution time of 2 seconds exceeded

Hi there :slight_smile:

This is my first post here :slight_smile: please can someone tell me what can be done ?
Upload and sync for small files (<600Mb) is working fine. But for large files (>4,5GB) uploaded in NC11 they can’t be accessed or even updated with NC12.
Upload or sync hangs after around 7mn
Is it due to change in fileupload mechanism ???.

Thanks

Error message :
Error
PHP
Maximum execution time of 2 seconds exceeded at /usr/share/nginx/html/nextcloud/lib/private/legacy/helper.php#299
Error
PHP
Maximum execution time of 2 seconds exceeded at /usr/share/nginx/html/nextcloud/apps/dav/lib/Upload/AssemblyStream.php#196

[error] 2642#2642: *4855 FastCGI sent in stderr: "PHP message: PHP Fatal error: Maximum execution time of 2 seconds exceeded in /usr/share/nginx/html/nextcloud/3rdparty/icewind/streams/src/Wrapper.php

Nextcloud version : 12.0.3 and 12.0.4
Operating system and version (eg, Ubuntu 16.04): CentOS 7
Apache or nginx version : nginx 1.13 (also same with nginx 1.11 & 1.12)
PHP version : 5.6 (also same with php7.0)
Is this the first time you’ve seen this error?:
since upgraded to NC12

Can you reliably replicate it? (If so, please outline steps):
Yes.

Just setup system and try to upload a very huge file (>4,5GB)
Setup 1 : NC12 + PHP7 + PHP-FPM and using tcp socket

Setup 2: NC12 + nginx + PHP56 + PHP-FPM and using tcp socket

Setup 3: NC12 + nginx + PHP56 + PHP-FPM and using Unix socket

tuning of Nginx conf
#set max upload size
#client_max_body_size 128G;
#fastcgi_buffers 64 4K;
proxy_request_buffering off;
proxy_buffering off;

client_body_in_file_only clean;
client_body_buffer_size 32K;

#Adjust client timeouts
client_max_body_size 0;
#client_body_buffer_size 1k;
client_header_buffer_size 1k;
large_client_header_buffers 1 2k;
client_body_timeout 15s;
client_header_timeout 15s;
keepalive_timeout 15s;
send_timeout 600s; #old value 15s
sendfile on;
tcp_nopush on;
tcp_nodelay on;

setup PHP-FPM
php_admin_value[upload_max_filesize] = 10G
php_admin_value[post_max_size] = 10G
php_admin_value[max_input_time] = 12h
php_admin_value[max_execution_time] = 2h
php_admin_value[memory_limit] = 512M
php_admin_value[memory_limit] = 128M

tuning for sysctl.conf done. (Thanks to Nate Wiger)

Tried with :
MacOSX :
Web interface (firefox 64bit)
Webdav client (Mountain Duck)
NC sync client 2.3.3

Windows 8/10 x64:
IE
Firefox
Webdav client (NetDrive2)
NC Sync client

The issue you are facing:
Server-Error at the end of with NC windows client sync
or upload reset by peer while trying to load file with web browser

The output of your Nextcloud log in Admin > Logging:

{“reqId”:“vgZjFpYGTp97im3BfLzg”,“level”:4,“time”:“2017-12-23T09:32:09+01:00”,“remoteAddr”:“83.X.X.X”,“user”:“MyAdmin”,“app”:“webdav”,“method”:“PUT”,“url”:"/remote.php/webdav/XXXXX%2020170907.3dm",“message”:“Exception: {“Exception”:“Sabre\\DAV\\Exception\\BadRequest”,“Message”:“expected filesize 4772411471 got 5234688”,“Code”:0,“Trace”:”#0 \/usr\/share\/nginx\/html\/nextcloud\/apps\/dav\/lib\/Connector\/Sabre\/Directory.php(151): OCA\\DAV\\Connector\\Sabre\\File->put(Resource id #11)\n#1 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(1096): OCA\\DAV\\Connector\\Sabre\\Directory->createFile(‘EGREEZR 20170907…’, Resource id #11)\n#2 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/CorePlugin.php(525): Sabre\\DAV\\Server->createFile(‘EGREEZR 20170907…’, Resource id #11, NULL)\n#3 [internal function]: Sabre\\DAV\\CorePlugin->httpPut(Object(Sabre\\HTTP\\Request), Object(Sabre\\HTTP\\Response))\n#4 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/event\/lib\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\n#5 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(479): Sabre\\Event\\EventEmitter->emit(‘method:PUT’, Array)\n#6 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(254): Sabre\\DAV\\Server->invokeMethod(Object(Sabre\\HTTP\\Request), Object(Sabre\\HTTP\\Response))\n#7 \/usr\/share\/nginx\/html\/nextcloud\/apps\/dav\/appinfo\/v1\/webdav.php(76): Sabre\\DAV\\Server->exec()\n#8 \/usr\/share\/nginx\/html\/nextcloud\/remote.php(162): require_once(’\/usr\/share\/ngin…’)\n#9 {main}",“File”:"\/usr\/share\/nginx\/html\/nextcloud\/apps\/dav\/lib\/Connector\/Sabre\/File.php",“Line”:151}",“userAgent”:“Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0”,“version”:“12.0.4.3”}
{“reqId”:“LQvgCGOManAFlJ3dDfi1”,“level”:3,“time”:“2017-12-23T09:48:43+01:00”,“remoteAddr”:“83.X.X.X”,“user”:“MyShared”,“app”:“PHP”,“method”:“PUT”,“url”:"/remote.php/webdav/EGREEZR%2020170907.3dm",“message”:“Maximum execution time of 2 seconds exceeded at /usr/share/nginx/html/nextcloud/lib/private/legacy/helper.php#298”,“userAgent”:“Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0”,“version”:“12.0.4.3”}
{“reqId”:“niVDdJur0T05JLyspRmt”,“level”:4,“time”:“2017-12-23T09:49:19+01:00”,“remoteAddr”:“83.X.X.X”,“user”:“MyShared”,“app”:“webdav”,“method”:“PUT”,“url”:"/remote.php/webdav/EGREEZR%2020170907.3dm",“message”:“Exception: {“Exception”:“Sabre\\DAV\\Exception\\BadRequest”,“Message”:“expected filesize 4772411471 got 9142272”,“Code”:0,“Trace”:”#0 \/usr\/share\/nginx\/html\/nextcloud\/apps\/dav\/lib\/Connector\/Sabre\/Directory.php(151): OCA\\DAV\\Connector\\Sabre\\File->put(Resource id #11)\n#1 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(1096): OCA\\DAV\\Connector\\Sabre\\Directory->createFile(‘EGREEZR 20170907…’, Resource id #11)\n#2 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/CorePlugin.php(525): Sabre\\DAV\\Server->createFile(‘EGREEZR 20170907…’, Resource id #11, NULL)\n#3 [internal function]: Sabre\\DAV\\CorePlugin->httpPut(Object(Sabre\\HTTP\\Request), Object(Sabre\\HTTP\\Response))\n#4 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/event\/lib\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\n#5 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(479): Sabre\\Event\\EventEmitter->emit(‘method:PUT’, Array)\n#6 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(254): Sabre\\DAV\\Server->invokeMethod(Object(Sabre\\HTTP\\Request), Object(Sabre\\HTTP\\Response))\n#7 \/usr\/share\/nginx\/html\/nextcloud\/apps\/dav\/appinfo\/v1\/webdav.php(76): Sabre\\DAV\\Server->exec()\n#8 \/usr\/share\/nginx\/html\/nextcloud\/remote.php(162): require_once(’\/usr\/share\/ngin…’)\n#9 {main}",“File”:"\/usr\/share\/nginx\/html\/nextcloud\/apps\/dav\/lib\/Connector\/Sabre\/File.php",“Line”:151}",“userAgent”:“Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0”,“version”:“12.0.4.3”}
{“reqId”:“VPZJB6hknEsSySAy4pCF”,“level”:3,“time”:“2017-12-23T11:51:42+01:00”,“remoteAddr”:“83.X.X.X”,“user”:“MyShared”,“app”:“PHP”,“method”:“PUT”,“url”:"/remote.php/webdav/EGREEZR%2020170907.3dm",“message”:“Maximum execution time of 2 seconds exceeded at /usr/share/nginx/html/nextcloud/lib/private/legacy/helper.php#298”,“userAgent”:“Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0”,“version”:“12.0.4.3”}
{“reqId”:“hlVXdNciImjciGQfsdRM”,“level”:4,“time”:“2017-12-23T11:52:13+01:00”,“remoteAddr”:“83.X.X.X”,“user”:“MyShared”,“app”:“webdav”,“method”:“PUT”,“url”:"/remote.php/webdav/EGREEZR%2020170907.3dm",“message”:“Exception: {“Exception”:“Sabre\\DAV\\Exception\\BadRequest”,“Message”:“expected filesize 4772411471 got 2646016”,“Code”:0,“Trace”:”#0 \/usr\/share\/nginx\/html\/nextcloud\/apps\/dav\/lib\/Connector\/Sabre\/Directory.php(151): OCA\\DAV\\Connector\\Sabre\\File->put(Resource id #11)\n#1 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(1096): OCA\\DAV\\Connector\\Sabre\\Directory->createFile(‘EGREEZR 20170907…’, Resource id #11)\n#2 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/CorePlugin.php(525): Sabre\\DAV\\Server->createFile(‘EGREEZR 20170907…’, Resource id #11, NULL)\n#3 [internal function]: Sabre\\DAV\\CorePlugin->httpPut(Object(Sabre\\HTTP\\Request), Object(Sabre\\HTTP\\Response))\n#4 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/event\/lib\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\n#5 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(479): Sabre\\Event\\EventEmitter->emit(‘method:PUT’, Array)\n#6 \/usr\/share\/nginx\/html\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php(254): Sabre\\DAV\\Server->invokeMethod(Object(Sabre\\HTTP\\Request), Object(Sabre\\HTTP\\Response))\n#7 \/usr\/share\/nginx\/html\/nextcloud\/apps\/dav\/appinfo\/v1\/webdav.php(76): Sabre\\DAV\\Server->exec()\n#8 \/usr\/share\/nginx\/html\/nextcloud\/remote.php(162): require_once(’\/usr\/share\/ngin…’)\n#9 {main}",“File”:"\/usr\/share\/nginx\/html\/nextcloud\/apps\/dav\/lib\/Connector\/Sabre\/File.php",“Line”:151}",“userAgent”:“Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0”,“version”:“12.0.4.3”}
{“reqId”:“NFB4pa9lYzPjiCEXTddp”,“level”:3,“time”:“2017-12-23T11:59:53+01:00”,“remoteAddr”:“83.X.X.X”,“user”:“MyAdmin”,“app”:“PHP”,“method”:“POST”,“url”:"/settings/admin/mailtest",“message”:“Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set ‘always_populate_raw_post_data’ to ‘-1’ in php.ini and use the php://input stream instead. at Unknown#0”,“userAgent”:“Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0”,“version”:“12.0.4.3”}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php $CONFIG = array ( 'instanceid' => 'niceinstanceisn'tit?', 'passwordsalt' => 'whatanicesecret', 'secret' => 'whatanicesecret', 'trusted_domains' => array ( 0 => 'nicenameherechanged.com', 1 => 'localnameherechanged', ), 'datadirectory' => '/userdata/data', 'overwrite.cli.url' => 'changeddns.to.theserver.com', 'dbtype' => 'mysql', 'version' => '12.0.4.3', 'dbname' => 'nextcloud_db', 'dbhost' => 'localhost', 'dbport' => '', 'dbtableprefix' => 'oc_', 'dbuser' => 'mydbuser', 'dbpassword' => 'mydbpassword', 'logtimezone' => 'Europe/Paris', 'log_type' => 'owncloud', 'logfile' => '/userdata/data/nextcloud.log', 'loglevel' => 2, 'installed' => true, 'mail_smtpmode' => 'php', 'mail_from_address' => 'adressmail', 'mail_domain' => 'servernnnnnnnnn.fr', 'mail_smtphost' => 'smtp', 'mail_smtpport' => '587', 'mail_smtpauthtype' => 'LOGIN', 'mail_smtpauth' => 1, 'maintenance' => false, 'mail_smtpsecure' => 'ssl', 'updater.release.channel' => 'production', 'updater.secret' => 'MySecret', 'theme' => '', 'memcache.local' => '\OC\Memcache\Redis', 'redis' => array( 'host' => 'localhost', 'port' => 6379, ), 'memcache.locking' => '\OC\Memcache\Redis', ); ?>

The output of your nginx in /var/log/nginx/error.log:
can’t paste information here due to system limitation (2 http links max) on my first post

Found solution :
Error was that NC12 use more memory than NC11, then available RAM for PHP-FPM was reduced. Resizing number of fpm child solved my issue.