getsentry / sentry-laravel

The official Laravel SDK for Sentry (sentry.io)
https://sentry.io
MIT License
1.24k stars 188 forks source link

SQLSTATE[HY000]: General error: 2006 MySQL server has gone away #872

Closed fhferreira closed 5 months ago

fhferreira commented 6 months ago

How do you use Sentry?

Sentry SaaS (sentry.io)

SDK version

4.1.1

Steps to reproduce

laravel/framework                      v6.20.44               The Laravel Framework.
laravel/horizon                           v3.7.2                 Dashboard and code-driven configuration for Laravel queues.
sentry/sentry-laravel                 4.1.1                  Laravel SDK for Sentry (https://sentry.io)

Jobs on HORIZON

Expected result

Jobs finishes without any issue, and looking at DB no failed_job and the code looks that have worked successful but we received the issues on sentry.

Actual result

SQLSTATE[HY000]: General error: 2006 MySQL server has gone away (SQL: select * from table_x where id = 123 limit 1)

Here apparently I have the same false positive with laravel-sentry related in the issue below:

https://github.com/laravel/horizon/issues/583#issuecomment-2020910963

stayallive commented 6 months ago

Hey! I don't see how this has anything to do with Sentry specifically? We just report errors we (should) not be responsable for them. Do you believe this is caused by Sentry?

Reading laravel/horizon#583 the root cause was the use of Doctrine in a Laravel application, are you also using Doctrine?

fhferreira commented 6 months ago
carbonphp/carbon-doctrine-types           2.1.0                  Types to use Carbon in Doctrine
doctrine/annotations                      1.13.2                 Docblock Annotations Parser
doctrine/cache                            2.1.1                  PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc,...
doctrine/collections                      1.6.8                  PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                           3.2.0                  PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as ...
doctrine/deprecations                     v0.5.3                 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selective...
doctrine/event-manager                    1.1.1                  The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                        2.0.8                  PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plu...
doctrine/instantiator                     1.4.0                  A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                            1.2.3                  PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/persistence                      2.2.3                  The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.

the app where I have the issue ˆ

and the other with no issues:

carbonphp/carbon-doctrine-types            1.0.0                  Types to use Carbon in Doctrine
doctrine/annotations                       1.14.3                 Docblock Annotations Parser
doctrine/cache                             1.13.0                 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc...
doctrine/collections                       1.8.0                  PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                            2.13.3                 PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as...
doctrine/dbal                              2.13.9                 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations                      1.1.3                  A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectiv...
doctrine/event-manager                     1.2.0                  The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                         1.4.4                  PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/pl...
doctrine/instantiator                      1.5.0                  A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                             1.2.3                  PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/persistence                       1.3.8                  The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers sh...
doctrine/reflection                        1.2.4                  The Doctrine Reflection project is a simple library used by the various Doctrine projects which adds some additional functiona...

all those packages are used here

fhferreira commented 6 months ago

maybe could be the versions of doctrine packages.

joeljohn135 commented 5 months ago

Try Adjusting your MySQL wait_timeout and max_allowed_packet settings to be more forgiving for long-running jobs or ensure your application keeps the connection alive. Or if you realize that its a sentry problem then exceptions reported by Sentry are not indicative of actual problems in your application, you can configure Sentry to ignore these specific exceptions.

stayallive commented 5 months ago

I still think this issue is not triggered by Sentry just captured and reported.

Thanks @joeljohn135 for chipping in, you hit it right on the nose and if you feel like you can safely ignore it you can check out the options we have for filtering and exclude the exception from being reported.

If you still feel like Sentry is somehow causing this I would love to check that out but I need a little more information and a reproduction case, this is a non-standard Laravel setup I have no experience with so a repoduction helps getting to the root of the issue if there is any.

But long story short I don't think it's reasonable that the Sentry SDK causes this issue.

fhferreira commented 5 months ago

I've updated horizon configurations with explicit retry_after and updated the package sentry, apparently the erros has gone.

sentry/sentry                              4.6.1                  PHP SDK for Sentry (http://sentry.io)
sentry/sentry-laravel                      4.4.0                  Laravel SDK for Sentry (https://sentry.io)