Issue Details (XML | Word | Printable)

Key: CORE-2752
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Dmitry Yemanov
Reporter: Vladimir Arkhipov
Votes: 0
Watchers: 3

If you were logged in you would be able to see more operations.
Firebird Core

Set the SO_KEEPALIVE option on the client TCP socket

Created: 13/Nov/09 04:00 PM   Updated: 24/May/16 04:00 PM
Component/s: API / Client Library
Affects Version/s: None
Fix Version/s: 2.5.1, 3.0 Alpha 1

QA Status: Cannot be tested

 Description  « Hide
It will be useful for server applications, which connects to remote firebird servers (for example, replication servers)

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Alexander Peshkov added a comment - 14/Nov/09 01:13 PM
Vladimir, SO_KEEPALIVE is used by server sockets to detect dead clients. I suppose you wish to check for dead server in your case. But client (unlike server) always can check, is server alife or not, using any API call (information, for example). Next, when server socket detects dead client, it has absolutely clear idea what to do - release all resources, required for that client. Can you explain what should be done in your example? Stop replication thread? Not sure this is good idea.

Vladimir Arkhipov added a comment - 14/Nov/09 08:14 PM
Yes, I wish to check for dead server (rather for connection abort). In my case replication thread is freezing for a long time (usually for unlimited time) and I want to detect it. Of course I can "ping" the remote port in separated thread, but connection may be already restored, anyway my exist database connection may be dead. More, I need to free this thread but closing database connection from another thread is not very safe. In addition I have many databases (about 30) and I need database pooling for each thread. And freezing prevent from normal processing of next databases in pool. And in this case SO_KEEPALIVE will be applicable.

Vladimir Arkhipov added a comment - 22/Nov/09 06:06 PM
What about resolution for this issue?

Dmitry Yemanov added a comment - 22/Nov/09 06:38 PM
I'm scheduling this ticket for v3.0, as v2.5 is already frozen for changes. BTW, I'm not really convinced this is a bug per se. It more looks like an improvement request.

Alexander Peshkov added a comment - 23/Nov/09 08:17 AM - edited
I'm still not absolutely sure that this will work. Keepalive packets are used to check for presence of the other side of network socket when there is *no* network activity on the socket. When replication request from server to another server is sent, it means presence of activity on the socket, therefore generic IP timeouts should work here.

Vladimir Arkhipov added a comment - 23/Nov/09 12:46 PM
Is it possible to use SO_RCVTIMEO and SO_SNDTIMEO socket options instead of SO_KEEPALIVE ?! But on some platforms these options may be unsupported. BTW, I agree that this issue is improvement, sorry :)

Frank Schlottmann-Goedde added a comment - 16/Dec/10 10:20 AM
In the meantime, until this has made it into the official codebase you may use <> for a workaround.

Vladimir Arkhipov added a comment - 20/Oct/11 10:15 AM
Can you append timeout parameters for KeepAlive sockets in firebird.conf for server and fbclient API for clients?
It will be more clear and easier for configuring and managing.

Dmitry Yemanov added a comment - 20/Oct/11 10:24 AM
These settings are system-wise, they don't belong exclusively to Firebird. So changing them at runtime (what may require admin rights, BTW) sounds like a bad idea.

Vladimir Arkhipov added a comment - 20/Oct/11 10:40 AM
I don't suggest to change system settings.
In Windows, for example, you can set SIO_KEEPALIVE_VALS in WSAIoctl function per connection.
I think in linux you can do it too.

Dmitry Yemanov added a comment - 20/Oct/11 10:52 AM
I'm not so sure regarding Linux and especially other unices.

Dmitry Yemanov added a comment - 20/Oct/11 10:58 AM
After some googling, it looks like IPPROTO_TCP + TCP_KEEPINTVL might make it possible. Not sure it's supported in all platforms though.

Vladimir Arkhipov added a comment - 20/Oct/11 11:50 AM
I think if it can be done in Windows and all Linux then this is sufficient for introducing this feature in Firebird. But it is your decision :)