Thread: message contents do not agree with length in message type "T"

message contents do not agree with length in message type "T"

From
"Mike"
Date:

Hello,

 

I’m using the libpq interface to PostgreSQL (8.3.0) in one of our apps, and I’m having a sporadic issue with receiving the error message:

 

--snip--

 

message contents do not agree with length in message type "T" server sent data ("D" message) without prior row description ("T" message)

 

--snip—

 

It doesn’t happen all the time, and doesn’t always happen on the same query.

 

--snip—

 

2008-03-10 22:09:29 [31010] - csql::query(): PGRES_FATAL_ERROR (message contents do not agree with length in message type "T" server sent data ("D" message) without prior row description ("T" message)) query='select fc_system_end_call(1867,6)'

 

2008-03-10 21:39:38 [30262] - csql::query(): PGRES_FATAL_ERROR (message contents do not agree with length in message type "T" server sent data ("D" message) without prior row description ("T" message)

) query='insert into system_stats (type,subject,stat_value,stat_data) values (501,0,9.027189,'')'

 

--snip—

 

In the first example, fc_system_end_call() is a plpgsql function

 

Schema |        Name        | Result data type |        Argument data types       

--------+--------------------+------------------+-----------------------------------

 public | fc_system_end_call | integer          | _call_id integer, _status integer

 

 

in the second example, system_stats is a table like:

 

                                     Table "public.system_stats"

   Column   |            Type             |                         Modifiers                        

------------+-----------------------------+-----------------------------------------------------------

 id         | bigint                      | not null default nextval('system_stats_id_seq'::regclass)

 date       | timestamp without time zone | not null default now()

 type       | smallint                    | not null

 subject    | bigint                      | not null default 0

 stat_value | double precision            | not null default 0

 stat_data  | text                        | not null default ''::text

Indexes:

    "system_stats_id_key" UNIQUE, btree (id)

Foreign-key constraints:

    "system_stats_type_fkey" FOREIGN KEY (type) REFERENCES system_stat_types(id) ON UPDATE CASCADE ON DELETE RESTRICT

 

--snip—

 

Does anybody have any idea what this message means, and could be the issue with what I’m doing?

 

I’m also sporatically getting these messages, and I’m not sure if they’re related or not?

 

--snip—

 

message type 0x54 arrived from server while idle

message type 0x44 arrived from server while idle

message type 0x43 arrived from server while idle

message type 0x5a arrived from server while idle

 

--snip--

 

Thanks for your time,

 

Mike

Re: message contents do not agree with length in message type "T"

From
Tom Lane
Date:
"Mike" <mike@mrhost.ca> writes:
> I'm using the libpq interface to PostgreSQL (8.3.0) in one of our apps, and
> I'm having a sporadic issue with receiving the error message:
> message contents do not agree with length in message type "T" server sent
> data ("D" message) without prior row description ("T" message)

The messages you're getting all mean that libpq has gotten out of sync
with the traffic that it's receiving from the server.  Now you might
have discovered some fascinating new bug in either libpq or the server,
but most of the reports like this that we've seen before have been
because someone tried to use libpq in a multi-threaded application
without sufficient interlocks to keep multiple threads from using the
same PGconn concurrently.  If your app has more than one thread then
please look at that closely.  If not, please see if you can put together
a test case ...

            regards, tom lane

Re: message contents do not agree with length in message type "T"

From
"Mike"
Date:
Thanks Tom,

That's definitely it- I've got a global database object that's used
throughout my application, it looks like I missed one crucial mutex lock in
the database code.

Thanks again,

Mike

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Monday, March 10, 2008 10:19 PM
To: Mike
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] message contents do not agree with length in message
type "T"

"Mike" <mike@mrhost.ca> writes:
> I'm using the libpq interface to PostgreSQL (8.3.0) in one of our apps,
and
> I'm having a sporadic issue with receiving the error message:
> message contents do not agree with length in message type "T" server sent
> data ("D" message) without prior row description ("T" message)

The messages you're getting all mean that libpq has gotten out of sync
with the traffic that it's receiving from the server.  Now you might
have discovered some fascinating new bug in either libpq or the server,
but most of the reports like this that we've seen before have been
because someone tried to use libpq in a multi-threaded application
without sufficient interlocks to keep multiple threads from using the
same PGconn concurrently.  If your app has more than one thread then
please look at that closely.  If not, please see if you can put together
a test case ...

            regards, tom lane