Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python client - mapi.Connection.__getbyes should throw exception when 0 bytes received from socket #3228

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Labels
bug Something isn't working Client interfaces normal

Comments

@monetdb-team
Copy link

Date: 2013-02-05 12:21:40 +0100
From: Pete Hollobon <>
To: clients devs <>
Version: 11.15.1 (Feb2013)
CC: pete

Last updated: 2013-03-07 12:41:21 +0100

Comment 18454

Date: 2013-02-05 12:21:40 +0100
From: Pete Hollobon <>

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.30 (KHTML, like Gecko) Chrome/26.0.1403.0 Safari/537.30
Build Identifier:

At present, the MonetDB Python client sleeps for one second and loops waiting for data if the length of the result from the socket communicating with the server is 0. However, a zero-length result from socket.recv means the server has closed the connection [1]. This means the client will hang if the server closes the socket for any reason.

In particular this happens when using VirtualBox and port-forwarding to run an OS running MonetDB, where MonetDB is not started. The connection is accepted by VirtualBox before it attempts to connect to the server process inside the VM. It's closed if there is no listening socket to connect to, causing the Python client to sit in this loop without timing out.

Here are patches for the Python 2 and 3 modules, which cause an exception to be thrown instead, which I think is the appropriate behaviour.

--- a/clients/python3/monetdb/mapi.py Thu Jan 31 15:05:41 2013 +0100
+++ b/clients/python3/monetdb/mapi.py Tue Feb 05 11:11:17 2013 +0000
@@ -237,7 +237,7 @@
while count > 0:
recv = self.socket.recv(count)
if len(recv) == 0:

  •            time.sleep(1)
    
  •            raise OperationalError("Server closed connection")
           logger.debug("II: package size: %i payload: %s" % (len(recv), recv))
           count -= len(recv)
           result.write(recv)
    

--- a/clients/python2/monetdb/mapi.py Tue Feb 05 11:11:17 2013 +0000
+++ b/clients/python2/monetdb/mapi.py Tue Feb 05 11:19:46 2013 +0000
@@ -235,7 +235,7 @@
try:
recv = self.socket.recv(count)
if len(recv) == 0:

  •                time.sleep(1)
    
  •                raise OperationalError("Server closed connection")
               logger.debug("II: package size: %i payload: %s" % (len(recv), recv))
           except socket.error, error:
               raise OperationalError(error[1])
    

[1] man recv

RETURN VALUE
... The return value will be 0 when the peer has performed an orderly shutdown.

Reproducible: Always

Comment 18570

Date: 2013-02-26 14:36:49 +0100
From: @sjoerdmullender

Changeset c22d45d3ea7e made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=c22d45d3ea7e

Changeset description:

Throw exception when server unexpectedly closes connection.
This fixes bug #3228.  Thanks to Pete Hollobon.

Comment 18571

Date: 2013-02-26 14:41:20 +0100
From: @sjoerdmullender

I'm not sure how to test this, so no test provided.

Comment 18588

Date: 2013-03-07 12:41:21 +0100
From: @sjoerdmullender

Feb2013-SP1 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Client interfaces normal
Projects
None yet
Development

No branches or pull requests

2 participants