MonetDB / pymonetdb

The Python API for MonetDB
https://www.monetdb.org/
Mozilla Public License 2.0
28 stars 20 forks source link

Connection refused log message when everything is fine #71

Closed bartscheers closed 4 years ago

bartscheers commented 4 years ago

Hi Gijs,

In the 1.3.1 release I noticed a INFO:pymonetdb.mapi:Connection refused message when everything is fine. Try this script for example on a clean instance (running on port 53001):

import logging
from pymonetdb.sql.connections import Connection as connect

logging.basicConfig(filename='testconn.log',level=logging.DEBUG)

conn = connect(hostname='localhost',database='testdb',port=53001,username='monetdb',password='monetdb')

c = conn.cursor()
c.execute("create table t1 (i int,d double)")
c.execute("insert into t1 (i,d) values (1,3.14)")
conn.commit()

c.execute("select * from t1")
r = c.fetchall()
print(r)

conn.close()

conn = connect(hostname='localhost',database='testdb',port=53001,username='monetdb',password='monetdb')

and you'll see a log file output like:

INFO:pymonetdb.mapi:Connection refused
DEBUG:pymonetdb.mapi:restarting authentication
DEBUG:pymonetdb.mapi:executing command Xauto_commit 0
DEBUG:pymonetdb.mapi:executing command Xsizeheader 1
DEBUG:pymonetdb.mapi:executing command Xreply_size 100
DEBUG:pymonetdb.mapi:executing command screate table t1 (i int,d double)
;
DEBUG:pymonetdb.mapi:executing command sinsert into t1 (i,d) values (1,3.14)
;
DEBUG:pymonetdb.mapi:executing command sCOMMIT
;
DEBUG:pymonetdb.mapi:executing command sselect * from t1
;
DEBUG:pymonetdb.mapi:executing command sROLLBACK
;
INFO:pymonetdb.mapi:disconnecting from database
INFO:pymonetdb.mapi:Connection refused
DEBUG:pymonetdb.mapi:restarting authentication
DEBUG:pymonetdb.mapi:executing command Xauto_commit 0
DEBUG:pymonetdb.mapi:executing command Xsizeheader 1
DEBUG:pymonetdb.mapi:executing command Xreply_size 100

Logging goes fine with the pymonetdb 1.1.1 version, without Connection refused messages.

Cheers

gijzelaerr commented 4 years ago

The behaviour changed slightly, and monetdb now supports IPv6 and IPv4, and also retrying with a new IP address if a hostname points to multiple IP addresses. My guess is that you are running a service on a machine with IPv6 but MonetDB is running on IPv4 only. Can you confirm this? If so, the solution to this confusion would be a better log message and a change of loglevel.

gijzelaerr commented 4 years ago

@bartscheers is this issue resolved for you?

bartscheers commented 4 years ago

Switching off the IPv6 service removed the connection messages. So it seems to be resolved or origin known.

gijzelaerr commented 4 years ago

ok so my analysis was correct and the error message is confusing. I'll change the message and log-level.

gijzelaerr commented 4 years ago

Fixed in master and 1.4.0