multi-tenant icon indicating copy to clipboard operation
multi-tenant copied to clipboard

queue retry uses system db connection instead of tenant

Open jeremyj11 opened this issue 2 years ago • 0 comments

Description

Retrying failed jobs via "php artisan queue:retry all" results in system database connection being used instead of tenant databse connection.


Actual behavior

Illuminate\Database\QueryException

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'SYSTEM.messages' doesn't exist (SQL: select * from messages where messages.id = 1554856 limit 1)

Expected behavior

The tenant databse connection should be used. use Hyn\Tenancy\Traits\UsesTenantConnection is being ignored in the model.


Information

  • hyn/multi-tenant version: 5.8.0
  • laravel version: 8
  • database driver and version: mariadb
  • php version: 8.2

Error log

php artisan queue:retry all

Illuminate\Database\QueryException

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sc4.messages' doesn't exist (SQL: select * from messages where messages.id = 1554856 limit 1)

at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712 708▕ // If an exception occurs when attempting to run a query, we'll format the error 709▕ // message to include the bindings with SQL, which will make this exception a 710▕ // lot more helpful to the developer instead of just the database's errors. 711▕ catch (Exception $e) { ➜ 712▕ throw new QueryException( 713▕ $query, $this->prepareBindings($bindings), $e 714▕ ); 715▕ } 716▕ }

• A table was not found: You might have forgotten to run your migrations. You can run your migrations using php artisan migrate. https://laravel.com/docs/master/migrations#running-migrations

1 [internal]:0 App\Jobs\SendMessage::__unserialize()

  +16 vendor frames 

18 [internal]:0 App\Jobs\SendMessage::__unserialize()

jeremyj11 avatar Sep 30 '22 10:09 jeremyj11