Lists: | pgsql-hackers |
---|
From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-28 11:38:57 |
Message-ID: | CAFj8pRAMDCJXjnwiCkCB1yO1f7NPggFY8PwwAJDnugu-Z2G-Cg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi
I workin with protocol and reading related code.
I found in routine EndCommand one strange thing
void
EndCommand(const QueryCompletion *qc, CommandDest dest, bool
force_undecorated_output)
{
<-->char<--><-->completionTag[COMPLETION_TAG_BUFSIZE];
<-->Size<--><-->len;
<-->switch (dest)
<-->{
<--><-->case DestRemote:
<--><-->case DestRemoteExecute:
<--><-->case DestRemoteSimple:
<--><--><-->len = BuildQueryCompletionString(completionTag, qc,
<--><--><--><--><--><--><--><--><--><--><--> force_undecorated_output);
<--><--><-->pq_putmessage(PqMsg_Close, completionTag, len + 1);
<--><-->case DestNone:
There is message PqMsgClose, but this should be used from client side. Here
should be used PqMsg_CommandComplete instead?
Regards
Pavel
From: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-28 12:00:26 |
Message-ID: | CAJ7c6TPYi5cvMpptYhr+DqBhPcVhciAG-n9kxBro_Q5=NXbY7w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi Pavel,
> There is message PqMsgClose, but this should be used from client side. Here should be used PqMsg_CommandComplete instead?
It seems so. This change was introduced in f4b54e1ed98 [1]:
```
--- a/src/backend/tcop/dest.c
+++ b/src/backend/tcop/dest.c
@@ -176,7 +176,7 @@ EndCommand(const QueryCompletion *qc, CommandDest
dest, bool force_undecorated_o
len = BuildQueryCompletionString(completionTag, qc,
force_undecorated_output);
- pq_putmessage('C', completionTag, len + 1);
+ pq_putmessage(PqMsg_Close, completionTag, len + 1);
case DestNone:
case DestDebug
```
It should have been PqMsg_CommandComplete.
[1]: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=f4b54e1ed98
--
Best regards,
Aleksander Alekseev
From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-28 14:01:29 |
Message-ID: | CAFj8pRBKa2ey+Nm_drj_5Fk-3_zBP7uezP2OrQT1pHeBO7m=6A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi
po 28. 8. 2023 v 14:00 odesílatel Aleksander Alekseev <
aleksander(at)timescale(dot)com> napsal:
> Hi Pavel,
>
> > There is message PqMsgClose, but this should be used from client side.
> Here should be used PqMsg_CommandComplete instead?
>
> It seems so. This change was introduced in f4b54e1ed98 [1]:
>
> ```
> --- a/src/backend/tcop/dest.c
> +++ b/src/backend/tcop/dest.c
> @@ -176,7 +176,7 @@ EndCommand(const QueryCompletion *qc, CommandDest
> dest, bool force_undecorated_o
>
> len = BuildQueryCompletionString(completionTag, qc,
>
> force_undecorated_output);
> - pq_putmessage('C', completionTag, len + 1);
> + pq_putmessage(PqMsg_Close, completionTag, len + 1);
>
> case DestNone:
> case DestDebug
> ```
>
> It should have been PqMsg_CommandComplete.
>
> [1]:
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=f4b54e1ed98
here is a patch - all tests passed
Regards
Pavel
>
>
> --
> Best regards,
> Aleksander Alekseev
>
Attachment | Content-Type | Size |
---|---|---|
fix_EmdCommandMessage.patch | text/x-patch | 519 bytes |
From: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-28 14:26:29 |
Message-ID: | CAJ7c6TNHQmv08KmOZN0dM61n-=3e9oojfob6gfinx-pvZ6Exaw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi,
> here is a patch - all tests passed
LGTM and added to the nearest CF just in case [1].
[1]: https://commitfest.postgresql.org/44/4523/
--
Best regards,
Aleksander Alekseev
From: | Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp> |
---|---|
To: | pavel(dot)stehule(at)gmail(dot)com |
Cc: | aleksander(at)timescale(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-28 21:12:00 |
Message-ID: | 20230829.061200.192005411012654565.t-ishii@sranhm.sra.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
>> Hi Pavel,
>>
>> > There is message PqMsgClose, but this should be used from client side.
>> Here should be used PqMsg_CommandComplete instead?
>>
>> It seems so. This change was introduced in f4b54e1ed98 [1]:
>>
>> ```
>> --- a/src/backend/tcop/dest.c
>> +++ b/src/backend/tcop/dest.c
>> @@ -176,7 +176,7 @@ EndCommand(const QueryCompletion *qc, CommandDest
>> dest, bool force_undecorated_o
>>
>> len = BuildQueryCompletionString(completionTag, qc,
>>
>> force_undecorated_output);
>> - pq_putmessage('C', completionTag, len + 1);
>> + pq_putmessage(PqMsg_Close, completionTag, len + 1);
>>
>> case DestNone:
>> case DestDebug
>> ```
>>
>> It should have been PqMsg_CommandComplete.
>>
>> [1]:
>> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=f4b54e1ed98
>
>
> here is a patch - all tests passed
I think EndReplicationCommand needs to be fixed as well.
Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp> |
Cc: | pavel(dot)stehule(at)gmail(dot)com, aleksander(at)timescale(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-28 22:53:37 |
Message-ID: | ZO0lcXlwln/Ir09S@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Aug 29, 2023 at 06:12:00AM +0900, Tatsuo Ishii wrote:
> I think EndReplicationCommand needs to be fixed as well.
Yeah, both of you are right here. Anyway, it seems to me that there
is a bit more going on in protocol.h. I have noticed two more things
that are incorrect:
- HandleParallelMessage is missing a message for 'P', but I think that
we should have a code for it as well as part of the parallel query
protocol.
- PqMsg_Terminate can be sent by the frontend *and* the backend, see
fe-connect.c and parallel.c. However, protocol.h documents it as a
frontend-only code.
--
Michael
From: | Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp> |
---|---|
To: | michael(at)paquier(dot)xyz |
Cc: | pavel(dot)stehule(at)gmail(dot)com, aleksander(at)timescale(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-29 01:04:24 |
Message-ID: | 20230829.100424.623781851282219189.t-ishii@sranhm.sra.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
> Yeah, both of you are right here. Anyway, it seems to me that there
> is a bit more going on in protocol.h. I have noticed two more things
> that are incorrect:
> - HandleParallelMessage is missing a message for 'P', but I think that
> we should have a code for it as well as part of the parallel query
> protocol.
I did not know this. Why is this not explained in the frontend/backend
protocol document?
> - PqMsg_Terminate can be sent by the frontend *and* the backend, see
> fe-connect.c and parallel.c. However, protocol.h documents it as a
> frontend-only code.
I do not blame protocol.h because our frontend/backend protocol
document also stats that it's a frontend only message. Someone who
started to use 'X' in backend should have added that in the
documentation.
Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp> |
Cc: | pavel(dot)stehule(at)gmail(dot)com, aleksander(at)timescale(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-29 07:39:51 |
Message-ID: | ZO2gx/W5bs/HpcBt@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Aug 29, 2023 at 10:04:24AM +0900, Tatsuo Ishii wrote:
>> Yeah, both of you are right here. Anyway, it seems to me that there
>> is a bit more going on in protocol.h. I have noticed two more things
>> that are incorrect:
>> - HandleParallelMessage is missing a message for 'P', but I think that
>> we should have a code for it as well as part of the parallel query
>> protocol.
>
> I did not know this. Why is this not explained in the frontend/backend
> protocol document?
Hmm. Thinking more about it, I am actually not sure that we need to
do that in this case, so perhaps things are OK as they stand for this
one.
>> - PqMsg_Terminate can be sent by the frontend *and* the backend, see
>> fe-connect.c and parallel.c. However, protocol.h documents it as a
>> frontend-only code.
>
> I do not blame protocol.h because our frontend/backend protocol
> document also stats that it's a frontend only message. Someone who
> started to use 'X' in backend should have added that in the
> documentation.
Actually, this may be OK as well as it stands. One can also say that
the parallel processing is out of this scope, being used only
internally. I cannot keep wondering whether we should put more
efforts in documenting the parallel worker/leader protocol. That's
internal to the backend and out of the scope of this thread, still..
--
Michael
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>, pavel(dot)stehule(at)gmail(dot)com, aleksander(at)timescale(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-29 14:01:47 |
Message-ID: | 1004809.1693317707@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Michael Paquier <michael(at)paquier(dot)xyz> writes:
> Actually, this may be OK as well as it stands. One can also say that
> the parallel processing is out of this scope, being used only
> internally. I cannot keep wondering whether we should put more
> efforts in documenting the parallel worker/leader protocol. That's
> internal to the backend and out of the scope of this thread, still..
Yeah. I'm not sure whether the leader/worker protocol needs better
documentation, but the parts of it that are not common with the
frontend protocol should NOT be documented in protocol.sgml.
That would just confuse authors of frontend code.
I don't mind having constants for the leader/worker protocol in
protocol.h, as long as they're in a separate section that's clearly
marked as relevant only for server-internal parallelism.
regards, tom lane
From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>, pavel(dot)stehule(at)gmail(dot)com, aleksander(at)timescale(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-29 16:15:55 |
Message-ID: | 20230829161555.GB2136737@nathanxps13 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi everyone,
Thanks for the report. I'll get this fixed up. My guess is that this was
leftover from an earlier version of the patch that used the same macro for
identical protocol characters.
On Tue, Aug 29, 2023 at 10:01:47AM -0400, Tom Lane wrote:
> Michael Paquier <michael(at)paquier(dot)xyz> writes:
>> Actually, this may be OK as well as it stands. One can also say that
>> the parallel processing is out of this scope, being used only
>> internally. I cannot keep wondering whether we should put more
>> efforts in documenting the parallel worker/leader protocol. That's
>> internal to the backend and out of the scope of this thread, still..
>
> Yeah. I'm not sure whether the leader/worker protocol needs better
> documentation, but the parts of it that are not common with the
> frontend protocol should NOT be documented in protocol.sgml.
> That would just confuse authors of frontend code.
>
> I don't mind having constants for the leader/worker protocol in
> protocol.h, as long as they're in a separate section that's clearly
> marked as relevant only for server-internal parallelism.
+1, I left the parallel stuff (and a couple other things) out in the first
round to avoid prolonging the naming discussion, but we can continue to add
to protocol.h.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>, pavel(dot)stehule(at)gmail(dot)com, aleksander(at)timescale(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-29 21:11:06 |
Message-ID: | 20230829211106.GA2266537@nathanxps13 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Aug 29, 2023 at 09:15:55AM -0700, Nathan Bossart wrote:
> Thanks for the report. I'll get this fixed up. My guess is that this was
> leftover from an earlier version of the patch that used the same macro for
> identical protocol characters.
I plan to commit the attached patch shortly.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Fix-misuse-of-PqMsg_Close.patch | text/x-diff | 1.3 KB |
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>, pavel(dot)stehule(at)gmail(dot)com, aleksander(at)timescale(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-29 22:56:33 |
Message-ID: | ZO53oWyMS8rvj0s0@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Aug 29, 2023 at 02:11:06PM -0700, Nathan Bossart wrote:
> I plan to commit the attached patch shortly.
WFM.
--
Michael
From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Tatsuo Ishii <ishii(at)sraoss(dot)co(dot)jp>, pavel(dot)stehule(at)gmail(dot)com, aleksander(at)timescale(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Wrong usage of pqMsg_Close message code? |
Date: | 2023-08-30 01:35:06 |
Message-ID: | 20230830013506.GA2483461@nathanxps13 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, Aug 30, 2023 at 07:56:33AM +0900, Michael Paquier wrote:
> On Tue, Aug 29, 2023 at 02:11:06PM -0700, Nathan Bossart wrote:
>> I plan to commit the attached patch shortly.
>
> WFM.
Committed.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com