From cc6fa312f034ee9753644013c9d19062252f2994 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 23 Oct 2021 16:32:06 +0200 Subject: [PATCH 1/2] Ensured minimum amount of task workers provided via config option or env var is 4 --- composer.json | 2 +- config/autoload/swoole.global.php | 32 ++++++++++++++++++------------- config/constants.php | 1 + 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 0ce15c6e..118ae244 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "shlinkio/shlink-config": "^1.2", "shlinkio/shlink-event-dispatcher": "^2.1", "shlinkio/shlink-importer": "^2.3.1", - "shlinkio/shlink-installer": "^6.2", + "shlinkio/shlink-installer": "^6.2.1", "shlinkio/shlink-ip-geolocation": "^2.0", "symfony/console": "^5.3", "symfony/filesystem": "^5.3", diff --git a/config/autoload/swoole.global.php b/config/autoload/swoole.global.php index 3db4cf5c..ad4e3792 100644 --- a/config/autoload/swoole.global.php +++ b/config/autoload/swoole.global.php @@ -4,22 +4,28 @@ declare(strict_types=1); use function Shlinkio\Shlink\Common\env; -return [ +use const Shlinkio\Shlink\MIN_TASK_WORKERS; - 'mezzio-swoole' => [ - // Setting this to true can have unexpected behaviors when running several concurrent slow DB queries - 'enable_coroutine' => false, +return (static function () { + $taskWorkers = (int) env('TASK_WORKER_NUM', 16); - 'swoole-http-server' => [ - 'host' => '0.0.0.0', - 'port' => (int) env('PORT', 8080), - 'process-name' => 'shlink', + return [ - 'options' => [ - 'worker_num' => (int) env('WEB_WORKER_NUM', 16), - 'task_worker_num' => (int) env('TASK_WORKER_NUM', 16), + 'mezzio-swoole' => [ + // Setting this to true can have unexpected behaviors when running several concurrent slow DB queries + 'enable_coroutine' => false, + + 'swoole-http-server' => [ + 'host' => '0.0.0.0', + 'port' => (int) env('PORT', 8080), + 'process-name' => 'shlink', + + 'options' => [ + 'worker_num' => (int) env('WEB_WORKER_NUM', 16), + 'task_worker_num' => $taskWorkers < MIN_TASK_WORKERS ? MIN_TASK_WORKERS : $taskWorkers, + ], ], ], - ], -]; + ]; +})(); diff --git a/config/constants.php b/config/constants.php index 43de270a..6c7aa09e 100644 --- a/config/constants.php +++ b/config/constants.php @@ -18,3 +18,4 @@ const DEFAULT_QR_CODE_SIZE = 300; const DEFAULT_QR_CODE_MARGIN = 0; const DEFAULT_QR_CODE_FORMAT = 'png'; const DEFAULT_QR_CODE_ERROR_CORRECTION = 'l'; +const MIN_TASK_WORKERS = 4; From 2b827baeed0fceef486acba4dfc3593d51fe5317 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 23 Oct 2021 16:35:38 +0200 Subject: [PATCH 2/2] Updated changelog --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e8dae6f..f895b28b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## [2.9.2] - 2021-10-23 ### Added * *Nothing* @@ -18,8 +18,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * *Nothing* ### Fixed -* [#1210](https://github.com/shlinkio/shlink/issues/1210) Fixed real time updates not being notified. +* [#1210](https://github.com/shlinkio/shlink/issues/1210) Fixed real time updates not being notified due to an incorrect handling of db transactions on multi-process tasks. * [#1211](https://github.com/shlinkio/shlink/issues/1211) Fixed `There is no active transaction` error when running migrations in MySQL/Mariadb after updating to doctrine-migrations 3.3. +* [#1197](https://github.com/shlinkio/shlink/issues/1197) Fixed amount of task workers provided via config option or env var not being validated to ensure enough workers to process all parallel tasks. ## [2.9.1] - 2021-10-11