Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run Concurrency with session driver dynamodb #52833

Closed
emiliopedrollo opened this issue Sep 17, 2024 · 3 comments
Closed

Cannot run Concurrency with session driver dynamodb #52833

emiliopedrollo opened this issue Sep 17, 2024 · 3 comments

Comments

@emiliopedrollo
Copy link
Contributor

Laravel Version

11.23.5

PHP Version

8.3.11

Database Driver & Version

PostgreSQL 16.3 on alpine linux (docker)

Description

Cannot execute Concurrency::run() while having session driver set as DynamoDB.

Got the following RuntimeException: "Instances of Aws\DynamoDB\DynamoDbClient cannot be serialized. The exception is thrown on Aws\AwsClient@__sleep() which is called by Laravel\SerializableClosure\Serializers\Signed@__serialize:

#0 [internal function]: Aws\AwsClient->__sleep()
#1 /var/www/api/vendor/laravel/serializable-closure/src/Serializers/Signed.php(68): serialize(Object(Laravel\SerializableClosure\Serializers\Native))
#2 [internal function]: Laravel\SerializableClosure\Serializers\Signed->__serialize()
#3 /var/www/api/vendor/laravel/framework/src/Illuminate/Concurrency/ProcessDriver.php(35): serialize(Object(Laravel\SerializableClosure\SerializableClosure))
#4 [internal function]: Illuminate\Concurrency\ProcessDriver->Illuminate\Concurrency\{closure}(Object(Illuminate\Process\Pool))
#5 /var/www/api/vendor/laravel/framework/src/Illuminate/Process/Pool.php(68): call_user_func(Object(Closure), Object(Illuminate\Process\Pool))
#6 /var/www/api/vendor/laravel/framework/src/Illuminate/Concurrency/ProcessDriver.php(42): Illuminate\Process\Pool->start()
#7 /var/www/api/vendor/laravel/framework/src/Illuminate/Support/MultipleInstanceManager.php(226): Illuminate\Concurrency\ProcessDriver->run(Array)
#8 /var/www/api/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(358): Illuminate\Support\MultipleInstanceManager->__call('run', Array)
#9 /var/www/api/app/Http/Controllers/v2/SearchController.php(264): Illuminate\Support\Facades\Facade::__callStatic('run', Array)
#10 /var/www/api/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Controllers\v2\FarmController->internalSearch(Object(App\Http\Searches\SearchRequest))

Steps To Reproduce

  1. Create a controller with a method containing some concurrency code like provided on the doc page:
use Illuminate\Support\Facades\Concurrency;
use Illuminate\Support\Facades\DB;

public function __invoke() {
 
  [$userCount, $orderCount] = Concurrency::run([
      fn () => DB::table('users')->count(),
      fn () => DB::table('orders')->count(),
  ]);

  return ['users' => $userCount, 'orders' => $orderCount ];
}
  1. Define a route to access the new controller.

  2. Setup session driver for dynamodb on config/session.php:

return [
    \\ ...
    'session' => 'dynamodb'
    \\ ...
]
  1. Start server:
php artisan serve
  1. Access the route.
@crynobone
Copy link
Member

There nothing here that would indicate Concurrency need to serialize session data.

@crynobone
Copy link
Member

Hey there, thanks for reporting this issue.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?

Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

@emiliopedrollo
Copy link
Contributor Author

While creating this repo I found out that the issue really is passing a request variable into a concurrent closure while using DyanmoDB. I'll close this issue and work on a new one with better description and more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants