Open-source multiplayer game server compatible with the RuneScape client https://www.openrs2.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
openrs2/db/src/main/java/dev/openrs2/db/PostgresDeadlockDetector.kt

17 lines
558 B

package dev.openrs2.db
import java.sql.SQLException
/**
* A [DeadlockDetector] implementation for PostgreSQL.
*/
public object PostgresDeadlockDetector : DeadlockDetector {
private const val SERIALIZATION_FAILURE = "40001"
private const val DEADLOCK_DETECTED = "40P01"
override fun isDeadlock(ex: SQLException): Boolean {
// see https://www.postgresql.org/docs/current/errcodes-appendix.html
val sqlState = ex.sqlState ?: return false
return sqlState == SERIALIZATION_FAILURE || sqlState == DEADLOCK_DETECTED
}
}