Opened 9 years ago

Last modified 6 years ago

#2627 new defect

v.out.postgis uses wrong database name or port

Reported by: wenzeslaus Owned by: grass-dev@…
Priority: normal Milestone: 7.2.4
Component: Default Version: svn-trunk
Keywords: PostgreSQL, postgres, PostGIS Cc:
CPU: Unspecified Platform: Unspecified

Description

After using db.connect and db.login:

db.connect driver=pg database="host=0.0.0.0,port=25432,dbname=gis"
db.login user=docker password=docker

v.out.postgis uses wrong database name or port (or both) and then fails to connect to the database and then crashes or hangs.

In the following reports I used g.gisenv set=DEBUG=5 but the behavior is the same for no debug. Note the name of database in debug messages is once "grass", then NULL and then "grass" plus some unknown/non-printable character. It also seems that it calls the read_file() function twice. Finally, it mentions 5432 before it ends.

Hangs:

D2/5: V1_open_new_pg(): name = busroutesall with_z = 0
D1/5: V1_open_new_pg(): conninfo='dbname=grass' table='busroutesall'
D3/5: db_get_login(): drv=[pg] db=[grass]
D3/5: read_file(): DB login file = </home/vpetras/.grass7/dblogin>
D3/5: ret = 4 : drv=[pg] db=[host=localhost,port=25432,dbname=gis] usr=[docker] pwd=[docker]
D3/5: db_get_login(): drv=[pg] db=[(null)]
D3/5: read_file(): DB login file = </home/vpetras/.grass7/dblogin>
D3/5: ret = 4 : drv=[pg] db=[host=localhost,port=25432,dbname=gis] usr=[docker] pwd=[docker]
D1/5:    PQconnectdb(): dbname=grass user=docker password=docker
ERROR: Connection to PostgreSQL database failed. Try to set up
       username/password by db.login.
       could not connect to server: No such file or directory
       Is the server running locally and accepting
       connections on Unix domain socket
       "/var/run/postgresql/.s.PGSQL.5432"?
D1/5: Vect_close(): name = busroutesall, mapset = PERMANENT, format = 0, level = 2, is_tmp = 0
D1/5: spatial index file closed
D1/5: close history file
D1/5: V1_close_nat(): name = busroutesall mapset= PERMANENT
D1/5: file_handler: PG_27099
D2/5: G_file_name(): path = /grassdata//nc_spm/postgis_test1/PG_27099

Aborted with "free(): invalid pointer":

D2/5: V1_open_new_pg(): name = busroutesall with_z = 0
D1/5: V1_open_new_pg(): conninfo='dbname=grass' table='busroutesall'
D3/5: db_get_login(): drv=[pg] db=[grass]
D3/5: read_file(): DB login file = </home/vpetras/.grass7/dblogin>
D3/5: ret = 4 : drv=[pg] db=[host=localhost,port=25432,dbname=gis] usr=[docker] pwd=[docker]
D3/5: db_get_login(): drv=[pg] db=[(null)]
D3/5: read_file(): DB login file = </home/vpetras/.grass7/dblogin>
D3/5: ret = 4 : drv=[pg] db=[host=localhost,port=25432,dbname=gis] usr=[docker] pwd=[docker]
D1/5:    PQconnectdb(): dbname=grass user=docker password=docker
ERROR: Connection to PostgreSQL database failed. Try to set up
       username/password by db.login.
       could not connect to server: No such file or directory
       Is the server running locally and accepting
       connections on Unix domain socket
       "/var/run/postgresql/.s.PGSQL.5432"?
D1/5: Vect_close(): name = busroutesall, mapset = PERMANENT, format = 0, level = 2, is_tmp = 0
D1/5: spatial index file closed
D1/5: close history file
D1/5: V1_close_nat(): name = busroutesall mapset= PERMANENT
D1/5: file_handler: PG_27257
D2/5: G_file_name(): path = /grassdata//nc_spm/postgis_test1/PG_27257
dbmi: Protocol error
* Error in `v.out.postgis': free(): invalid pointer: 0x00007f6fed3977e8 *
Aborted (core dumped)

Segmentation fault:

D2/5: V1_open_new_pg(): name = busroutesall with_z = 0
D1/5: V1_open_new_pg(): conninfo='dbname=grass' table='busroutesall'
D3/5: db_get_login(): drv=[pg] db=[grass]
D3/5: read_file(): DB login file = </home/vpetras/.grass7/dblogin>
D3/5: ret = 4 : drv=[pg] db=[host=localhost,port=25432,dbname=gis] usr=[docker] pwd=[docker]
D3/5: db_get_login(): drv=[pg] db=[(null)]
D3/5: read_file(): DB login file = </home/vpetras/.grass7/dblogin>
D3/5: ret = 4 : drv=[pg] db=[host=localhost,port=25432,dbname=gis] usr=[docker] pwd=[docker]
D1/5:    PQconnectdb(): dbname=grass user=docker password=docker
ERROR: Connection to PostgreSQL database failed. Try to set up
       username/password by db.login.
       could not connect to server: No such file or directory
       Is the server running locally and accepting
       connections on Unix domain socket
       "/var/run/postgresql/.s.PGSQL.5432"?
D1/5: Vect_close(): name = busroutesall, mapset = PERMANENT, format = 0, level = 2, is_tmp = 0
D1/5: spatial index file closed
D1/5: close history file
D1/5: V1_close_nat(): name = busroutesall mapset= PERMANENT
D1/5: file_handler: PG_27267
D2/5: G_file_name(): path = /grassdata//nc_spm/postgis_test1/PG_27267
dbmi: Protocol error
Segmentation fault (core dumped)

Similar applies to the case when v.out.postgis is used without db.login. Sometimes in hangs, sometimes it segfaults:

v.out.postgis -l input=busroutesall output="PG:dbname=grass"
ERROR: Connection to PostgreSQL database failed. Try to set up
       username/password by db.login.
       could not connect to server: No such file or directory
       Is the server running locally and accepting
       connections on Unix domain socket
       "/var/run/postgresql/.s.PGSQL.5432"?
dbmi: Protocol error
Segmentation fault (core dumped)

Same as in #2626, I hope I'm not missing something, e.g. from manual or messages. The special thing about my environment is that I'm using PostgreSQL database in a Docker container from kartoza/postgis. I used their steps to run it and psql works for me (in GRASS session):

psql -h localhost -U docker -p 25432 -l

Change History (9)

comment:1 by neteler, 8 years ago

Milestone: 7.1.07.2.0

Milestone renamed

comment:2 by mlennert, 8 years ago

The handling of host and port info have changed (use db.login instead of db.connect for that info). Could you test whether this is still an issue for you in 7.2 ?

comment:3 by neteler, 7 years ago

ping

comment:4 by wenzeslaus, 7 years ago

I can't test this right now, can somebody else test it (same for #2626)? The issue here seemed to be non-standard port.

comment:5 by neteler, 7 years ago

Milestone: 7.2.07.2.1

Ticket retargeted after milestone closed

comment:6 by martinl, 7 years ago

Milestone: 7.2.17.2.2

comment:7 by neteler, 7 years ago

Milestone: 7.2.27.2.3

Ticket retargeted after milestone closed

comment:8 by martinl, 6 years ago

Milestone: 7.2.3

Ticket retargeted after milestone closed

comment:9 by martinl, 6 years ago

Milestone: 7.2.4
Note: See TracTickets for help on using tickets.