Re: libpq async duplicate error results
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>,
Fabien COELHO <coelho@cri.ensmp.fr>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-05-06T15:47:34Z
Lists: pgsql-hackers
Attachments
- reset-libpq-command-queue-more-correctly-wip.patch (text/x-diff) patch
I wrote: > What is happening is that this bit in PQsendQueryStart is deciding > not to clear the message buffer because conn->cmd_queue_head isn't > NULL: > /* > * If this is the beginning of a query cycle, reset the error state. > * However, in pipeline mode with something already queued, the error > * buffer belongs to that command and we shouldn't clear it. > */ > if (newQuery && conn->cmd_queue_head == NULL) > pqClearConnErrorState(conn); > So apparently the fault is with the pipelined-query logic. I'm > not sure what cleanup step is missing though. I experimented with the attached patch, which is based on the idea that clearing the command queue is being done in entirely the wrong place. It's more appropriate to do it where we drop unsent output data, ie in pqDropConnection not pqDropServerData. The fact that it was jammed into the latter without any commentary doesn't do much to convince me that that placement was thought about carefully. This fixes the complained-of symptom and still passes check-world. However, I wonder whether cutting the queue down to completely empty is the right thing. Why is the queue set up like this in the first place --- that is, why don't we remove an entry the moment the command is sent? I also wonder whether pipelineStatus ought to get reset here. We aren't resetting asyncStatus here, so maybe it's fine, but I'm not quite sure. regards, tom lane
Commits
-
libpq: drop pending pipelined commands in pqDropConnection().
- 93909599cdba 15.0 landed
-
Adjust interaction of libpq pipeline mode with errorMessage resets.
- b15f254466ae 15.0 landed
-
Rearrange libpq's error reporting to avoid duplicated error text.
- 618c16707a6d 15.0 landed
-
In libpq, always append new error messages to conn->errorMessage.
- ffa2e4670123 14.0 cited