[6.x] Fix sqlsrv reuses broken connection #30362
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Starting with Laravel 6.x, once in a while one of my queue jobs throws an exception:
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.