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

[6.x] Fix sqlsrv reuses broken connection #30362

Merged
merged 1 commit into from Oct 21, 2019

Conversation

@Namoshek
Copy link
Contributor

Namoshek commented Oct 21, 2019

Starting with Laravel 6.x, once in a while one of my queue jobs throws an exception:

SQLSTATE[08S01]: [Microsoft][ODBC Driver 17 for SQL Server]The connection is no longer usable because the server response for a previously executed statement was incorrectly formatted.

As can be seen in the error message, I'm using the SQL Server driver. Unfortunately, I couldn't locate the exact issue so far. It only occured within the queue workers until now, not within the application itself. No very rare jobs are executed, it happens within very regularly executed jobs (i.e. it's unlikely the code of the jobs is the issue).

In general, it doesn't botter me too much as it only happens once a week so far with an average job count of 50k per week. The problem is that the queue workers simply escalate the exception of the job and then reuse the broken connection. To solve this, the PR attempts to force a reconnect if the exceptions contains the mentioned error message. This seems a very fitting strategy as the error explicitely says the connection is no longer usable.

The error itself seems to be very rare as there are next to no reports even outside the Laravel community.

@mpyw
mpyw approved these changes Oct 21, 2019
@taylorotwell taylorotwell merged commit ce9eadc into laravel:6.x Oct 21, 2019
2 checks passed
2 checks passed
continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@GrahamCampbell GrahamCampbell changed the title Fix: sqlsrv reuses broken connection [6.x] Fix sqlsrv reuses broken connection Oct 21, 2019
ginnerpeace added a commit to ginnerpeace/framework that referenced this pull request Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.