[SR-Users] Problem with reconnection to database server

Henning Westerholt hw at kamailio.org
Tue Sep 4 21:49:21 CEST 2018


Am Dienstag, 4. September 2018, 15:17:20 CEST schrieb Minh Phan:
> My Kamailio instance is disconnected from database server (Postgres) quite
> often (after running for some days) and it won't manage to reconnect. Any
> idea why this happens? Normally it try to reconnect when connection with
> the DB is lost, desn't it? Bellow are the related log messages.

Hello Minh,

yes, normally Kamailio should reconnect to the database when the connection is 
lost.

One reasons that the connection is lost could be a misbehaving firewall or 
simple network stability issues between the Kamailio and the database server.

You can try to enable the tcp_keepalive function, to help to keep the 
connection open:

3.3. tcp_keepalive (integer)   

   Enable the TCP keepalive timer and set the number of seconds the
   connection must be idle before to start sending keepalive packets.
   Defaults to zero, which disables TCP keepalive packets.

   Only supported on platforms which understand and support the
   “TCP_KEEPIDLE” socket option.

Best regards,

Henning


> Sep  4 11:31:20 : ERROR: <core> [db_query.c:235]: db_do_insert_cmd(): error
> while submitting query
> Sep  4 11:31:20 : ERROR: db_postgres [km_dbase.c:559]:
> db_postgres_store_result(): invalid query, execution aborted
> Sep  4 11:31:20 : ERROR: db_postgres [km_dbase.c:561]:
> db_postgres_store_result(): driver error: PGRES_FATAL_ERROR,
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:609]:
> db_postgres_insert(): unexpected result returned
> Sep  4 11:31:20 : ERROR: topos [tps_storage.c:599]: tps_db_insert_dialog():
> failed to store message
> Sep  4 11:31:20 : ERROR: topos [tps_storage.c:412]: tps_storage_record():
> failed to store
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : ERROR: db_postgres [km_dbase.c:267]:
> db_postgres_submit_query(): 0x2b11c92b8b18 PQsendQuery Error:  Query:
> select
> rectime,a_callid,a_uuid,b_uuid,direction,x_via,x_vbranch,x_rr,y_rr,s_rr,x_ur
> i,x_tag,s_method,s_cseq,a_contact,b_contact,as_contact,bs_contact,a_tag,b_ta
> g from topos_t where
> x_vbranch='z9hG4bK66fa.3f007792000000000000000000000000.0'
> Sep  4 11:31:20 : ERROR: <core> [db_query.c:132]: db_do_query_internal():
> error while submitting query
> Sep  4 11:31:20 : ERROR: topos [tps_storage.c:961]: tps_db_load_branch():
> failed to query database
> Sep  4 11:31:20 : WARNING: topos [tps_storage.c:400]: tps_storage_record():
> no local address - do record routing for all initial requests
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 kamailio[26608]: WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 kamailio[26608]: WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : ERROR: db_postgres [km_dbase.c:267]:
> db_postgres_submit_query(): 0x2b11c92b8b18 PQsendQuery Error:  Query:
> insert into topos_d
> (rectime,a_callid,a_uuid,b_uuid,a_contact,b_contact,as_contact,bs_contact,a_
> tag,b_tag,a_rr,b_rr,s_rr,iflags,a_uri,b_uri,r_uri,a_srcaddr,b_srcaddr,s_meth
> od,s_cseq ) values ('2018-09-04
> 11:31:20','1ff8d1d7606f7416-26611 at 192.168.70.106
> ','','','','','','','ae86e22a93159b5c6ac75234cdf26c1b-44e5','','','','',0,'
> ','','','','','OPTIONS','10') Sep  4 11:31:20 kamailio[26608]: WARNING:
> db_postgres [km_dbase.c:259]: db_postgres_submit_query(): postgres query
> command failed, connection status 1, error [no connection to the
> server#012]
> Sep  4 11:31:20 : ERROR: <core> [db_query.c:235]: db_do_insert_cmd(): error
> while submitting query
> Sep  4 11:31:20 kamailio[26608]: ERROR: db_postgres [km_dbase.c:267]:
> db_postgres_submit_query(): 0x2b11c92b8b18 PQsendQuery Error:  Query:
> select
> rectime,a_callid,a_uuid,b_uuid,direction,x_via,x_vbranch,x_rr,y_rr,s_rr,x_ur
> i,x_tag,s_method,s_cseq,a_contact,b_contact,as_contact,bs_contact,a_tag,b_ta
> g from topos_t where
> x_vbranch='z9hG4bK86fa.424ded00000000000000000000000000.0'
> Sep  4 11:31:20 kamailio[26608]: ERROR: <core> [db_query.c:132]:
> db_do_query_internal(): error while submitting query
> Sep  4 11:31:20 : ERROR: db_postgres [km_dbase.c:559]:
> db_postgres_store_result(): invalid query, execution aborted
> Sep  4 11:31:20 kamailio[26608]: ERROR: topos [tps_storage.c:961]:
> tps_db_load_branch(): failed to query database
> Sep  4 11:31:20 : ERROR: db_postgres [km_dbase.c:561]:
> db_postgres_store_result(): driver error: PGRES_FATAL_ERROR,
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:609]:
> db_postgres_insert(): unexpected result returned
> Sep  4 11:31:20 : ERROR: topos [tps_storage.c:599]: tps_db_insert_dialog():
> failed to store message
> Sep  4 11:31:20 : ERROR: topos [tps_storage.c:412]: tps_storage_record():
> failed to store
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : ERROR: db_postgres [km_dbase.c:267]:
> db_postgres_submit_query(): 0x2b11c92b8b18 PQsendQuery Error:  Query:
> select
> rectime,a_callid,a_uuid,b_uuid,direction,x_via,x_vbranch,x_rr,y_rr,s_rr,x_ur
> i,x_tag,s_method,s_cseq,a_contact,b_contact,as_contact,bs_contact,a_tag,b_ta
> g from topos_t where
> x_vbranch='z9hG4bK76fa.d33cc801000000000000000000000000.0'
> Sep  4 11:31:20 : ERROR: <core> [db_query.c:132]: db_do_query_internal():
> error while submitting query
> Sep  4 11:31:20 : ERROR: topos [tps_storage.c:961]: tps_db_load_branch():
> failed to query database
> Sep  4 11:31:20 : WARNING: topos [tps_storage.c:400]: tps_storage_record():
> no local address - do record routing for all initial requests
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : WARNING: db_postgres [km_dbase.c:259]:
> db_postgres_submit_query(): postgres query command failed, connection
> status 1, error [no connection to the server#012]
> Sep  4 11:31:20 : ERROR: db_postgres [km_dbase.c:267]:
> db_postgres_submit_query(): 0x2b11c92b8b18 PQsendQuery Error:  Query:
> insert into topos_d
> (rectime,a_callid,a_uuid,b_uuid,a_contact,b_contact,as_contact,bs_contact,a_
> tag,b_tag,a_rr,b_rr,s_rr,iflags,a_uri,b_uri,r_uri,a_srcaddr,b_srcaddr,s_meth
> od,s_cseq ) values ('2018-09-04
> 11:31:20','1ff8d1d7606f7417-26611 at 192.168.70.106
> ','','','','','','','ae86e22a93159b5c6ac75234cdf26c1b-917f','','','','',0,'
> ','','','','','OPTIONS','10') Sep  4 11:31:20 : ERROR: <core>
> [db_query.c:235]: db_do_insert_cmd(): error while submitting query
> Sep  4 11:31:20 : ERROR: db_postgres [km_dbase.c:559]:
> db_postgres_store_result(): invalid query, execution aborted
> Sep  4 11:31:20 : ERROR: db_postgres [km_dbase.c:561]:
> db_postgres_store_result(): driver error: PGRES_FATAL_ERROR,


-- 
Henning Westerholt
https://skalatan.de/blog/



More information about the sr-users mailing list