fix: retry mysql connections on message DB pool

This commit is contained in:
Adam Cooke
2024-02-13 15:56:40 +00:00
parent b8cb563553
commit f9f7fb30fe
2 changed files with 20 additions and 1 deletions
@@ -41,5 +41,16 @@ describe Postal::MessageDB::ConnectionPool do
end.to raise_error Mysql2::Error
expect(pool.connections).to eq []
end
it "retries the block once if there is a connection error" do
clients_seen = []
expect do
pool.use do |client|
clients_seen << client
raise Mysql2::Error, "lost connection to server"
end
end.to raise_error Mysql2::Error
expect(clients_seen.uniq.size).to eq 2
end
end
end