How to debug the wire protocol?

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

Hello,

I’ve sent a similar email to the general mailing list but got no reply.

I’m trying to write my own implementation of the wire protocol. I’m stuck at the Parse message where I send it to the server but always get the following error: “Could not parse statement invalid string in message”

Is there a way to see how Postgres parses the message? I’ve set logging to DEBUG5 but the only thing I can see in the logs is, among other things, the message

ERROR: invalid string in message
FATAL: invalid frontend message type 63

What is exactly wrong? Is there a way to log the parsing of the message, or should I create my own build of postgres with log statements where I need them?

Many thanks,

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

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Rui Pacheco (#1)
Re: How to debug the wire protocol?

Hi

2017-02-09 20:01 GMT+01:00 Rui Pacheco <rui.pacheco@gmail.com>:

Hello,

I’ve sent a similar email to the general mailing list but got no reply.

I’m trying to write my own implementation of the wire protocol. I’m stuck
at the Parse message where I send it to the server but always get the
following error: “Could not parse statement invalid string in message”

Is there a way to see how Postgres parses the message? I’ve set logging to
DEBUG5 but the only thing I can see in the logs is, among other things, the
message

ERROR: invalid string in message
FATAL: invalid frontend message type 63

What is exactly wrong? Is there a way to log the parsing of the message,
or should I create my own build of postgres with log statements where I
need them?

https://github.com/dalibo/pgshark

Regards

Pavel

Show quoted text

Many thanks,

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

#3Rui Pacheco
rui.pacheco@gmail.com
In reply to: Pavel Stehule (#2)
Re: How to debug the wire protocol?

Not sure this solves my problem. I’d like to debug how the server is failing to parse my message, not what it looks like on the wire. I am the one forming the message after all.

My apologies if I missed something.

Show quoted text

On 9 Feb 2017, at 20:05, Pavel Stehule <pavel.stehule@gmail.com> wrote:

Hi

2017-02-09 20:01 GMT+01:00 Rui Pacheco <rui.pacheco@gmail.com <mailto:rui.pacheco@gmail.com>>:
Hello,

I’ve sent a similar email to the general mailing list but got no reply.

I’m trying to write my own implementation of the wire protocol. I’m stuck at the Parse message where I send it to the server but always get the following error: “Could not parse statement invalid string in message”

Is there a way to see how Postgres parses the message? I’ve set logging to DEBUG5 but the only thing I can see in the logs is, among other things, the message

ERROR: invalid string in message
FATAL: invalid frontend message type 63

What is exactly wrong? Is there a way to log the parsing of the message, or should I create my own build of postgres with log statements where I need them?

https://github.com/dalibo/pgshark <https://github.com/dalibo/pgshark&gt;

Regards

Pavel

Many thanks,

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org <mailto:pgsql-hackers@postgresql.org>)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers <http://www.postgresql.org/mailpref/pgsql-hackers&gt;

#4Pavel Stehule
pavel.stehule@gmail.com
In reply to: Rui Pacheco (#3)
Re: How to debug the wire protocol?

2017-02-09 20:12 GMT+01:00 Rui Pacheco <rui.pacheco@gmail.com>:

Not sure this solves my problem. I’d like to debug how the server is
failing to parse my message, not what it looks like on the wire. I am the
one forming the message after all.

My apologies if I missed something.

ok

no problem

Regards

Pavel

Show quoted text

On 9 Feb 2017, at 20:05, Pavel Stehule <pavel.stehule@gmail.com> wrote:

Hi

2017-02-09 20:01 GMT+01:00 Rui Pacheco <rui.pacheco@gmail.com>:

Hello,

I’ve sent a similar email to the general mailing list but got no reply.

I’m trying to write my own implementation of the wire protocol. I’m stuck
at the Parse message where I send it to the server but always get the
following error: “Could not parse statement invalid string in message”

Is there a way to see how Postgres parses the message? I’ve set logging
to DEBUG5 but the only thing I can see in the logs is, among other things,
the message

ERROR: invalid string in message
FATAL: invalid frontend message type 63

What is exactly wrong? Is there a way to log the parsing of the message,
or should I create my own build of postgres with log statements where I
need them?

https://github.com/dalibo/pgshark

Regards

Pavel

Many thanks,

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

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Rui Pacheco (#1)
Re: How to debug the wire protocol?

Rui Pacheco <rui.pacheco@gmail.com> writes:

I’ve sent a similar email to the general mailing list but got no reply.

Uh, multiple people answered you, see
/messages/by-id/22DB2E08-6329-4EF8-B3E5-C0A7728A067B@gmail.com

Is there a way to see how Postgres parses the message? I’ve set logging to DEBUG5 but the only thing I can see in the logs is, among other things, the message

ERROR: invalid string in message
FATAL: invalid frontend message type 63

That seems to comport with the theory I suggested before, that you were
sending an incorrect message length word --- although this additional
evidence indicates that the sent length is too short, not too long
which is what I'd been thinking. Or possibly you left out required
field(s) of the message. Anyway it's expecting a null-terminated string
and not finding one in the remaining message data.

regards, tom lane

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

#6Rui Pacheco
rui.pacheco@gmail.com
In reply to: Tom Lane (#5)
Re: How to debug the wire protocol?

I’ve been anxiously waiting for that reply but got nothing. I even mailed the mailing list manager again with no reply. And when I click on that link I get a server error: "An internal server error occurred.”

But thanks, this helps me focus on the problem.

Show quoted text

On 9 Feb 2017, at 20:15, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Rui Pacheco <rui.pacheco@gmail.com> writes:

I’ve sent a similar email to the general mailing list but got no reply.

Uh, multiple people answered you, see
/messages/by-id/22DB2E08-6329-4EF8-B3E5-C0A7728A067B@gmail.com

Is there a way to see how Postgres parses the message? I’ve set logging to DEBUG5 but the only thing I can see in the logs is, among other things, the message

ERROR: invalid string in message
FATAL: invalid frontend message type 63

That seems to comport with the theory I suggested before, that you were
sending an incorrect message length word --- although this additional
evidence indicates that the sent length is too short, not too long
which is what I'd been thinking. Or possibly you left out required
field(s) of the message. Anyway it's expecting a null-terminated string
and not finding one in the remaining message data.

regards, tom lane

#7Andres Freund
andres@anarazel.de
In reply to: Rui Pacheco (#6)
Re: How to debug the wire protocol?

On 2017-02-09 20:17:33 +0100, Rui Pacheco wrote:

I’ve been anxiously waiting for that reply but got nothing. I even mailed the mailing list manager again with no reply. And when I click on that link I get a server error: "An internal server error occurred.”

The server error has already been fixed, please reload...

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

#8Rui Pacheco
rui.pacheco@gmail.com
In reply to: Andres Freund (#7)
Re: How to debug the wire protocol?

The answers are great, thanks!

On 9 Feb 2017, at 20:26, Andres Freund <andres@anarazel.de> wrote:

On 2017-02-09 20:17:33 +0100, Rui Pacheco wrote:

I’ve been anxiously waiting for that reply but got nothing. I even mailed the mailing list manager again with no reply. And when I click on that link I get a server error: "An internal server error occurred.”

The server error has already been fixed, please reload...

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