Fix sql connection recycling bug causing multiple connection reopens

Currently when multiple sql statements that share the same structure
are prepared they are put in a statement cache as preparing them is an
expensive operation. This patch fixes a bug where a non primary
connection would not recycle its opened connection due to it believing
that the pool did not have space caused by a one off error which in turn
caused the connection to be rebuilt every time it was requested.

Bug: 228498581
Test: Verified caching with logs and confirmed savings in traces
Change-Id: Ic7e26db77c23d8ead9565a689800cc48f158c059
2 files changed