craftcms / commerce

Fully integrated ecommerce for Craft CMS.
https://craftcms.com/commerce
Other
226 stars 170 forks source link

[4.x]: "exec(): Unable to fork [stty -a 2>&1]" on php craft commerce/upgrade/run #3139

Closed Romanavr closed 1 year ago

Romanavr commented 1 year ago

What happened?

Description

As part of a craft & commerce upgrade, after successfully applying migrations, I run php craft commerce/upgrade/run and I was prompted for field handles. After that, the customer migration process started, at the end of which I got this error

Some of the existing addresses contain data that will need to be stored in custom fields:
 - Business ID
 - Phone Number
 - Custom 1
Do you have a custom field for storing Business ID values? (yes|no) [no]:yes
Enter the field handle for storing Business ID values: businessId
Do you have a custom field for storing Phone Number values? (yes|no) [no]:yes
Enter the field handle for storing Phone Number values: phoneNumber
Do you have a custom field for storing Custom 1 values? (yes|no) [no]:
Let’s create one then.
Field handle: [addressCustom1] customDeprecated1
Field name: [Custom 1]
Creating a user for every customer…
[======================================================================>      ] 91% (1846/2026) ETA: 13 sec.
Error: exec(): Unable to fork [stty -a 2>&1]

I tried this several times by increasing various PHP options for the CLI (e.g. max_execution_time and memory_limit) but each time I got an error at the same percentage (and number) I solved this problem by uploading the production database locally, running upgrade and then re-uploading again to live website. So locally I don't have any problems. I have a few more sites that I need to update to the new craft and commerce so I want to understand what could be causing this and how can it be resolved? Also, important note. Before this, I ran the same update on the staging site(same server) and didn't experience any issues, but it was a different version for craft and commerce: Craft Pro 4.3.6.1 and Commerce 4.2.4

Steps to reproduce

  1. Try to run php craft commerce/upgrade/run after upgrade to craft & commerce 4.x

Expected behavior

There shouldn't be error

Actual behavior

An error occurs

Trace log:

yii\base\ErrorException: exec(): Unable to fork [stty -a 2>&1]
#22 /vendor/yiisoft/yii2/helpers/BaseConsole.php(713): yii\base\ErrorHandler::handleError
#21 [internal](0): exec
#20 /vendor/yiisoft/yii2/helpers/BaseConsole.php(713): yii\helpers\BaseConsole::getScreenSize
#19 /vendor/yiisoft/yii2/helpers/BaseConsole.php(1094): yii\helpers\BaseConsole::getProgressbarWidth
#18 /vendor/yiisoft/yii2/helpers/BaseConsole.php(1049): yii\helpers\BaseConsole::updateProgress
#17 /vendor/craftcms/commerce/src/console/controllers/UpgradeController.php(1017): craft\commerce\console\controllers\UpgradeController::_migrateCustomers
#16 /vendor/craftcms/commerce/src/console/controllers/UpgradeController.php(254): craft\commerce\console\controllers\UpgradeController::craft\commerce\console\controllers\{closure}
#15 [internal](0): call_user_func
#14 /vendor/yiisoft/yii2/db/Connection.php(818): yii\db\Connection::transaction
#13 /vendor/craftcms/commerce/src/console/controllers/UpgradeController.php(288): craft\commerce\console\controllers\UpgradeController::actionRun
#12 [internal](0): call_user_func_array
#11 /vendor/yiisoft/yii2/base/InlineAction.php(57): yii\base\InlineAction::runWithParams
#10 /vendor/yiisoft/yii2/base/Controller.php(178): yii\base\Controller::runAction
#9 /vendor/yiisoft/yii2/console/Controller.php(180): yii\console\Controller::runAction
#8 /vendor/craftcms/cms/src/console/ControllerTrait.php(87): craft\console\Controller::traitRunAction
#7 /vendor/craftcms/cms/src/console/Controller.php(217): craft\console\Controller::runAction
#6 /vendor/yiisoft/yii2/base/Module.php(552): yii\base\Module::runAction
#5 /vendor/yiisoft/yii2/console/Application.php(180): yii\console\Application::runAction
#4 /vendor/craftcms/cms/src/console/Application.php(90): craft\console\Application::runAction
#3 /vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application::handleRequest
#2 /vendor/craftcms/cms/src/console/Application.php(121): craft\console\Application::handleRequest
#1 /vendor/yiisoft/yii2/base/Application.php(384): yii\base\Application::run
#0 /craft(23): null

Craft CMS version

Craft Pro 4.4.7

Craft Commerce version

4.2.6

PHP version

8.1.16

Operating system and version

Linux 5.4.0-135-generic

Database type and version

MySQL 8.0.31

Image driver and version

craftcms/nginx:8.1-dev locally

Installed plugins and versions

-

angrybrad commented 1 year ago

I'd guess it's a ulimit issue on the box you're seeing the error on https://stackoverflow.com/questions/20648949/php-warning-exec-unable-to-fork

Bumping that might work around it. If you also want to send over a pre-update attempt database dump and composer.json/lock files to support@craftcms.com, we'll see if there is something we can do on the application side to work around the error, too.

Romanavr commented 1 year ago

Done. Please let me know if there is any that would help.

Romanavr commented 1 year ago

The problem was in the limit of open files, ulimit -n 65535 resolved the problem. Thanks @angrybrad for the help.