ozo: connection pool error: get resource timeout
I keep seeing ozo::error_code’s with the following value and message.
yamail::resource_pool::error::detail::category:1
get resource timeout
This is happening in the middle of my application’s activities, where database activity is happening normally for several minutes already.
I’m using the default ozo::connection_pool_config
settings.
I’m connecting to a database-as-a-service database in “the cloud”, and have a pgBouncer load balance configured and managed by my service provider, so there shouldn’t be any issues with connecting to the database, or a problem with limited number of connection slots available.
Could I get an explanation of possible causes for this error?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (8 by maintainers)
For anyone reading along, I’ve implemented this functionality in an application-specific way, like such:
First, run SQL code similar to this:
Which takes several arrays of data points, which all must be the same length.
The function then iterates over each array, and executes your function of preference with the values provided.
In my case, the
handle_telemetry_result()
function looks up which function to execute based on the telemetryid that I provide, and executes it with the ID and contents provided.Then, in your C++ code, something like this’ll do the trick.
In this way, you only send data to the database when you don’t already have a database operation in flight, and then as soon as that in-flight operation returns, another operation is triggered to send any data that has accumulated in the mean time.
Compared to simply having one DB connection per operation, this increases your average latency substantially. However, DB connections aren’t free, and you’re almost always limited to a small number of them, so it’s generally worth the trade off if you’re not very concerned about latency.
Is this a perfect solution? No, of course not. The only real solution to this problem is for libpq to gain the ability to use a single connection for multiple queries at the same time… even if the queries are all executed in serial on the database, just having less dead air is a substantial reduction in latency.
But that’s out of the OZO library’s control. So this is what I’m using until that feature is implemented.