Score:1

Idle database connection lost

in flag

I am able to connect to the database server (Firebird), run queries, all those fun things, but after an undetermined period of inactivity, the next query attempt generates the following error

Unable to complete network request to host "XX.XX.XX.XX".
Error writing data to the connection.
An existing connection was forcibly closed by the remote host. .

SQL Error (code = -902):
Unsuccessful execution caused by a system error that precludes
successful execution of subsequent statements.

When operating interactively using Firebird Maestro (relevance unknown), after I get this error I tell Maestro to disconnect. I am then able to run a query.

I don't know whether the timeout is coming from Firebird or the Linux server or elsewhere on our network and I don't know enough about Linux or AWS or our network to know where to look for possibilities. (the joys of being a programmer at a very small company)

sk flag
I'm not very familiar with Firebird, and you don't mention what program/language the error is coming from, but you probably just need to enable KeepAlives in the connection setup/configuration (ie, when your client software makes the connection, specify keepalives).
WeststarEric avatar
in flag
@ChrisS So you are suggesting that I should ignore the part about "forcibly closed by the remote host" and try to override the behavior on the client end? Unfortunately that gets into how Maestro or my programming tool works and I think that is off topic for this forum.
Score:0
ae flag

Regardless of where the timeout comes from, you should be prepared for it. It's possible there are even multiple timeouts in place and your connection would be thrown away anyway after a period of inactivity.

It's best to use a connection-pooling library and specify a shorter timeout than what you observe right now (unless it's unacceptably low).

It could help if you described your deployment in details but I think, ultimately, you need to fix the client side.

WeststarEric avatar
in flag
I can see how a connection pool would make it less likely for a connection to go inactive if there are numerous simultaneous users. In the likely event that there is only one user, I would like to know what is causing the disconnect so I can take control of the timeout period.
ae flag
You haven't told us much about your deployment so it's not easy to give you any advice on that. Connection pooling makes sense even if you have only one user. I recommend HikariCP: https://github.com/brettwooldridge/HikariCP#microscope-analyses - their timeout configuration might be interesting too: https://github.com/brettwooldridge/HikariCP#microscope-analyses
WeststarEric avatar
in flag
Unfortunately I have told you everything I know about "my" deployment. Small company, lots of turnover, not much expertise. I was hoping for some hints about where to look.
ae flag
You sure know more than that. You haven't mentioned any specifics about the application or the machines that host the app and the database. Anyway, have you checked their docs? https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref40/fblangref40-management-timeouts.html
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.