Capsule
2 years ago
Concerns
3 weeks ago
Connectors
3 weeks ago
Console
3 weeks ago
DBAL
3 weeks ago
Eloquent
3 weeks ago
Events
3 weeks ago
Migrations
3 weeks ago
PDO
3 weeks ago
Query
3 weeks ago
Schema
3 weeks ago
ClassMorphViolationException.php
2 years ago
ConfigurationUrlParser.php
2 years ago
Connection.php
3 weeks ago
ConnectionInterface.php
2 years ago
ConnectionResolver.php
3 weeks ago
ConnectionResolverInterface.php
2 years ago
DatabaseManager.php
3 weeks ago
DatabaseServiceProvider.php
3 weeks ago
DatabaseTransactionRecord.php
3 weeks ago
DatabaseTransactionsManager.php
3 weeks ago
DeadlockException.php
3 weeks ago
DetectsConcurrencyErrors.php
2 years ago
DetectsLostConnections.php
3 weeks ago
Grammar.php
3 weeks ago
LazyLoadingViolationException.php
2 years ago
LostConnectionException.php
3 weeks ago
MigrationServiceProvider.php
3 weeks ago
MultipleColumnsSelectedException.php
3 weeks ago
MultipleRecordsFoundException.php
3 weeks ago
MySqlConnection.php
3 weeks ago
PostgresConnection.php
3 weeks ago
QueryException.php
2 years ago
RecordsNotFoundException.php
2 years ago
SQLiteConnection.php
3 weeks ago
SQLiteDatabaseDoesNotExistException.php
3 weeks ago
Seeder.php
3 weeks ago
SqlServerConnection.php
3 weeks ago
DetectsConcurrencyErrors.php
26 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWPSCOPED\Illuminate\Database; |
| 4 | |
| 5 | use IAWPSCOPED\Illuminate\Support\Str; |
| 6 | use PDOException; |
| 7 | use Throwable; |
| 8 | /** @internal */ |
| 9 | trait DetectsConcurrencyErrors |
| 10 | { |
| 11 | /** |
| 12 | * Determine if the given exception was caused by a concurrency error such as a deadlock or serialization failure. |
| 13 | * |
| 14 | * @param \Throwable $e |
| 15 | * @return bool |
| 16 | */ |
| 17 | protected function causedByConcurrencyError(Throwable $e) |
| 18 | { |
| 19 | if ($e instanceof PDOException && ($e->getCode() === 40001 || $e->getCode() === '40001')) { |
| 20 | return \true; |
| 21 | } |
| 22 | $message = $e->getMessage(); |
| 23 | return Str::contains($message, ['Deadlock found when trying to get lock', 'deadlock detected', 'The database file is locked', 'database is locked', 'database table is locked', 'A table in the database is locked', 'has been chosen as the deadlock victim', 'Lock wait timeout exceeded; try restarting transaction', 'WSREP detected deadlock/conflict and aborted the transaction. Try restarting the transaction']); |
| 24 | } |
| 25 | } |
| 26 |