mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Add ConnectionRefused exception
* required to fix retry+connection initialization corner case.
This commit is contained in:
parent
4c74e6c9da
commit
2ca60ba43f
2 changed files with 13 additions and 0 deletions
|
@ -11,6 +11,9 @@ module DB
|
||||||
class PoolRetryAttemptsExceeded < Error
|
class PoolRetryAttemptsExceeded < Error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Raised when an established connection is lost
|
||||||
|
# probably due to socket/network issues.
|
||||||
|
# It is used by the connection pool retry logic.
|
||||||
class ConnectionLost < Error
|
class ConnectionLost < Error
|
||||||
getter connection : Connection
|
getter connection : Connection
|
||||||
|
|
||||||
|
@ -18,6 +21,12 @@ module DB
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Raised when a connection is unable to be established
|
||||||
|
# probably due to socket/network or configuration issues.
|
||||||
|
# It is used by the connection pool retry logic.
|
||||||
|
class ConnectionRefused < Error
|
||||||
|
end
|
||||||
|
|
||||||
class Rollback < Exception
|
class Rollback < Exception
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -93,6 +93,10 @@ module DB
|
||||||
# and remove it from the known pool.
|
# and remove it from the known pool.
|
||||||
delete(e.connection)
|
delete(e.connection)
|
||||||
e.connection.close
|
e.connection.close
|
||||||
|
rescue e : ConnectionRefused
|
||||||
|
# a ConnectionRefused means a new connection
|
||||||
|
# was intented to be created
|
||||||
|
# nothing to due but to retry soon
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
raise PoolRetryAttemptsExceeded.new
|
raise PoolRetryAttemptsExceeded.new
|
||||||
|
|
Loading…
Reference in a new issue