Closed michaelnguyen2021 closed 5 years ago
Please post your horizon, queue, database & telescope configs.
FYI, I start getting the Deadlock QueryException after installing Telescope
// .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=cancab
DB_USERNAME=homestead
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=memcached
SESSION_DRIVER=redis
QUEUE_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
<?php
// horizon.php
return [
'use' => 'default',
'prefix' => env('HORIZON_PREFIX', 'horizon:'),
'waits' => [
'redis:default' => 60,
],
'trim' => [
'recent' => 60,
'failed' => 10080,
],
'environments' => [
'production' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['default', 'email', 'push', 'sms'],
'balance' => 'simple',
'processes' => 10,
'tries' => 3,
],
],
'local' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['default', 'email', 'push', 'sms'],
'balance' => 'simple',
'processes' => 3,
'tries' => 3,
],
],
],
];
// queue.php
<?php
return [
'default' => env('QUEUE_DRIVER', 'sync'),
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'retry_after' => 90,
],
'sqs' => [
'driver' => 'sqs',
'key' => 'your-public-key',
'secret' => 'your-secret-key',
'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
'queue' => 'your-queue-name',
'region' => 'us-east-1',
],
'redis' => [
'driver' => 'redis',
'connection' => 'queue',
'queue' => 'default',
'retry_after' => 90,
],
],
'failed' => [
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
];
// database.php
<?php
return [
'fetch' => PDO::FETCH_OBJ,
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
],
'migrations' => 'migrations',
'redis' => [
'cluster' => false,
'client' => 'predis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
'session' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 1,
],
'queue' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 2,
],
],
];
// telescope.php
<?php
use Laravel\Telescope\Watchers;
use Laravel\Telescope\Http\Middleware\Authorize;
return [
'path' => 'telescope',
'driver' => env('TELESCOPE_DRIVER', 'database'),
'storage' => [
'database' => [
'connection' => env('DB_CONNECTION', 'mysql'),
],
],
'limit' => env('TELESCOPE_LIMIT', 100),
'middleware' => [
'web',
Authorize::class,
],
'watchers' => [
Watchers\CacheWatcher::class => env('TELESCOPE_CACHE_WATCHER', true),
Watchers\CommandWatcher::class => env('TELESCOPE_COMMAND_WATCHER', true),
Watchers\DumpWatcher::class => env('TELESCOPE_DUMP_WATCHER', true),
Watchers\EventWatcher::class => env('TELESCOPE_EVENT_WATCHER', true),
Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true),
Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
Watchers\LogWatcher::class => env('TELESCOPE_LOG_WATCHER', true),
Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true),
Watchers\ModelWatcher::class => env('TELESCOPE_MODEL_WATCHER', true),
Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true),
Watchers\QueryWatcher::class => [
'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
'slow' => 100,
],
Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true),
Watchers\RequestWatcher::class => env('TELESCOPE_REQUEST_WATCHER', true),
Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true),
],
];
Heya thanks. After checking into this, I believe this is a Telescope specific issue. Let's continue the discussion there: https://github.com/laravel/telescope/issues/180
Sentry.io caught this (Telescope https://github.com/laravel/telescope/issues/180) - I have no ideas if Horizon or Telescope causes this
horizon.stats.index
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: insert intotelescope_entries
(batch_id
,content
,created_at
,type
,uuid
) values (8c1bafb1-0d89-48c3-a828-1fe95669c19f, {"type":"hit","key":"1qXuDwVKWrhXcgNzyq4rVlC5aB6t9y0xbBxZB07D","value":"a:5:{s:6:\"_token\";s:40:\"j8ohwNnI04jxDH9L0DSgnmrxX22lnzhI4T5VcIHq\";s:9:\"_previous\";a:1:{s:3:\"url\";s:37:\"http:\/\/localhost\/horizon\/api\/workload\";}s:22:\"PHPDEBUGBAR_STACK_DATA\";a:0:{}s:6:\"_flash\";a:2:{s:3:\"old\";a:0:{}s:3:\"new\";a:0:{}}s:52:\"login_admin_59ba36addc2b2f9401580f014c7f58ea4e30989d\";i:2;}","hostname":"homestead"}, 2018-10-25 22:09:55, cache, 8c1bafb0-9cca-4007-b765-92c75ddf2dc4), (8c1bafb1-0d89-48c3-a828-1fe95669c19f, {"uri":"horizon\/api\/stats","method":"GET","headers":{"cookie":"XSRF-TOKEN=eyJpdiI6InhNVUFIekYrYkRoRVg0eXFTQWkzQXc9PSIsInZhbHVlIjoiMWRZN0Myc25TQUdaN1wvZVFmc3FIbjRjU2RMUjBRaWZhNHpOUHN2VlgwYWI2YWxZTlFjdTExd1ZjUVhWVTZja0kiLCJtYWMiOiJlNmRmNzghorizon.masters.index
SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: delete from
telescope_entries
wheretype
= command andsequence
not in (selectsequence
from (selectsequence
fromtelescope_entries
wheretype
= command order bysequence
desc limit 100) asentries_temp
))