jackc / pgconn

MIT License
178 stars 86 forks source link

Received unexpected message #102

Closed mixmind closed 2 years ago

mixmind commented 2 years ago

Hi,

I faced with issue that driver dont know what to do with warnings that postgres backend throws during connection. Psql works fine, nothing shows and with pgx I'm having trouble to connect at all.

pgconn.go line 326 was changed to this

default: pgConn.conn.Close() fmt.Printf("%+v,%T", msg, msg) return nil, &connectError{config: config, msg: "received unexpected message", err: err}

When i changed code to print what is going on, i received such message

results
&{Severity:WARNING SeverityUnlocalized:WARNING Code:01000 Message:1 temporary files and directories not closed at end-of-transaction Detail: Hint: Position:0 InternalPosition:0 InternalQuery: Where: SchemaName: TableName: ColumnName: DataTypeName: ConstraintName: File:fd.c Line:3021 Routine:CleanupTempFiles UnknownFields:map[]},*pgproto3.NoticeResponseUnable to connect to database: failed to connect to `host=/var/run/postgresql user=postgres database=postgres`: received unexpected message

Can it be handled without error from pgx side?

It can be repsoduced if postgresql parameter will be changed to client_min_messages = debug5 , every connect to db will fail with such error : received unexpected message

example of response with config changed to debug5

results
{"Severity":"DEBUG","SeverityUnlocalized":"DEBUG","Code":"00000","Message":"CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0","Detail":"","Hint":"","Position":0,"InternalPosition":0,"InternalQuery":"","Where":"","SchemaName":"","TableName":"","ColumnName":"","DataTypeName":"","ConstraintName":"","File":"xact.c","Line":5182,"Routine":"ShowTransactionStateRec","UnknownFields":null}
jackc commented 2 years ago

The connection issue is fixed in 05d532b5df9e43f11a521f61529404aedb578212.

However, running with that verbose of a client log level may cause other problems. See #27.

mixmind commented 2 years ago

The connection issue is fixed in 05d532b.

However, running with that verbose of a client log level may cause other problems. See #27.

Great, it helped. Thanks