Logging broken messages

Started by Rui Pachecoabout 9 years ago4 messagesgeneral
Jump to latest
#1Rui Pacheco
rui.pacheco@gmail.com

Hello,

I’m trying to implement a version of the wire protocol but I’ve hit a problem: whenever I send a Close Statement message to the remote, it just hangs indefinitely. I suspect the problem could be on my side but I can’t find anything on my code that doesn’t match the manual <https://www.postgresql.org/docs/9.5/static/protocol-message-formats.html&gt;.

Is there a way to configure Postgres to debug this? I’ve tried setting a number of log parameters but nothing shows up on syslog:

postgres=# show log_destination
postgres-# ;
log_destination
-----------------
syslog
(1 row)

postgres=# SET log_statement = 'all';
SET
postgres=# set log_min_messages = 'DEBUG5';
SET
postgres=# set log_min_error_statement = 'DEBUG5';
SET
postgres=# show syslog_ident;
syslog_ident
--------------
postgres
(1 row)

postgres=#

Many thanks,

#2Steve Atkins
steve@blighty.com
In reply to: Rui Pacheco (#1)
Re: Logging broken messages

On Feb 6, 2017, at 9:21 AM, Rui Pacheco <rui.pacheco@gmail.com> wrote:

Hello,

I’m trying to implement a version of the wire protocol but I’ve hit a problem: whenever I send a Close Statement message to the remote, it just hangs indefinitely. I suspect the problem could be on my side but I can’t find anything on my code that doesn’t match the manual.

Is there a way to configure Postgres to debug this? I’ve tried setting a number of log parameters but nothing shows up on syslog:

Wireshark has a v3 postgresql protocol dissector. It might be worth comparing your code with libpq and see if anything looks different.

Cheers,
Steve

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Steve Atkins (#2)
Re: Logging broken messages

Steve Atkins <steve@blighty.com> writes:

On Feb 6, 2017, at 9:21 AM, Rui Pacheco <rui.pacheco@gmail.com> wrote:
I’m trying to implement a version of the wire protocol but I’ve hit a problem: whenever I send a Close Statement message to the remote, it just hangs indefinitely. I suspect the problem could be on my side but I can’t find anything on my code that doesn’t match the manual.

Is there a way to configure Postgres to debug this? I’ve tried setting a number of log parameters but nothing shows up on syslog:

Wireshark has a v3 postgresql protocol dissector. It might be worth comparing your code with libpq and see if anything looks different.

Also, you could try attaching to the connected backend with gdb and
look at where it's waiting.

To cut to the chase, though: I'd bet you are either sending a wrong
message length word, or failing to flush your buffer out to the socket.
Either way the backend would be sitting waiting to accumulate the
full message. If it had what it thought was a complete message, it
would be doing something with it --- either executing it or complaining.
But it doesn't really make any attempt to validate an incoming message
until it's got all of it as per the length word.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4John DeSoi
desoi@pgedit.com
In reply to: Rui Pacheco (#1)
Re: Logging broken messages

On Feb 6, 2017, at 11:21 AM, Rui Pacheco <rui.pacheco@gmail.com> wrote:

I’m trying to implement a version of the wire protocol but I’ve hit a problem: whenever I send a Close Statement message to the remote, it just hangs indefinitely. I suspect the problem could be on my side but I can’t find anything on my code that doesn’t match the manual.

I have written something like this recently without any problems. Maybe post the code if you think more eyes would be helpful.

John DeSoi, Ph.D.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general