Skip to content

Add heartbeat on the server - #4750

Merged
ajpotts merged 3 commits into
Bears-R-Us:mainfrom
vasslitvinov:heartbeat
Aug 6, 2025
Merged

ajpotts merged 3 commits into
Bears-R-Us:mainfrom
vasslitvinov:heartbeat

Conversation

@vasslitvinov

@vasslitvinov vasslitvinov commented Jul 29, 2025 •

Copy link
Copy Markdown
Contributor

This heartbeat allows client to recognize that the connection to the server went away while the server was processing a message from the client. The client raises an exception in this case. The heartbeat is activated by passing a positive number to the timeout argument of ak.connect().

While there, tidy up some code. Also, introduce ak.client.server_sleep(seconds) to enable testing of the heartbeat, and ak.client.note_for_server_log(message) to make it easier to track the tests being tested while examining arkouda.log.

Implementation-wise, this enables "TCP keepalive" on the ZMQ socket between the client and the server and adds a monitor for this socket on the client. After sending a request to the server, the client waits for a reply with a timeout. If it times out, the client checks the monitor for "closed "or "disconnected" events. If none, the client goes back to waiting for a server reply with a timeout. As before, there is no overall timeout for server response.

While there, moved test_no_op and test_ruok within client_test.py to match the relative position of _no_op and ruok within client.py.

Related: #1010

@lydia-duncan lydia-duncan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some questions and a couple of suggestions

Comment thread arkouda/client.py Resolved
Comment thread arkouda/client.py Resolved
Comment thread tests/client_test.py Resolved
Comment thread tests/optioned-server/conftest.py Resolved
Comment thread tests/optioned-server/heartbeat.py Resolved

@ajpotts ajpotts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Comment thread arkouda/client.py Resolved
Comment thread arkouda/client.py Resolved
Comment thread arkouda/client.py Resolved
Comment thread arkouda/client.py Resolved
Comment thread arkouda/client.py Resolved
Comment thread arkouda/client.py Resolved
Comment thread arkouda/client.py Resolved
Signed-off-by: Vassily Litvinov <[email protected]>
Signed-off-by: Vassily Litvinov <[email protected]>
Signed-off-by: Vassily Litvinov <[email protected]>
@ajpotts
ajpotts added this pull request to the merge queue Aug 6, 2025
Merged via the queue into Bears-R-Us:main with commit 7bad705 Aug 6, 2025
@vasslitvinov
vasslitvinov deleted the heartbeat branch August 7, 2025 03:19
drculhane pushed a commit to drculhane/arkouda that referenced this pull request Aug 20, 2025
This heartbeat allows client to recognize that the connection to the
server went away while the server was processing a message from the
client. The client raises an exception in this case. The heartbeat is
activated by passing a positive number to the `timeout` argument of
`ak.connect()`.

While there, tidy up some code. Also, introduce
`ak.client.server_sleep(seconds)` to enable testing of the heartbeat,
and `ak.client.note_for_server_log(message)` to make it easier to track
the tests being tested while examining `arkouda.log`.

Implementation-wise, this enables "TCP keepalive" on the ZMQ socket
between the client and the server and adds a monitor for this socket on
the client. After sending a request to the server, the client waits for
a reply with a timeout. If it times out, the client checks the monitor
for "closed "or "disconnected" events. If none, the client goes back to
waiting for a server reply with a timeout. As before, there is no
overall timeout for server response.

While there, moved `test_no_op` and `test_ruok` within `client_test.py`
to match the relative position of `_no_op` and `ruok` within
`client.py`.

Related: Bears-R-Us#1010

---------

Signed-off-by: Vassily Litvinov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants