is ErrorResponse possible on Sync?

From: Andrei Matei <andreimatei1(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: is ErrorResponse possible on Sync?
Date: 2022-01-12 17:52:50
Message-ID: CABWLseub08wdSS0V63uK9gazbKLUysXcGizLcBk6+UUz9DpOhw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Postgres friends,

I've got a question about the wire protocol; the relevant text in the docs
seems a bit ambiguous to me. If the processing of a Sync message fails
(e.g. because the commit of the current transaction fails), is the backend
allowed to respond with an ErrorResponse, in addition to the ReadyForQuery
message? Or, does the backend swallow the error, and return only the
ReadyForQuery (I hope not).

The docs
<https://www.postgresql.org/docs/14/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY>
say:
"""
At completion of each series of extended-query messages, the frontend
should issue a Sync message. This parameterless message causes the backend
to close the current transaction if it's not inside a BEGIN/COMMIT
transaction block (“close” meaning to commit if no error, or roll back if
error). Then a ReadyForQuery response is issued. The purpose of Sync is to
provide a resynchronization point for error recovery. When an error is
detected while processing any extended-query message, the backend issues
ErrorResponse, then reads and discards messages until a Sync is reached,
then issues ReadyForQuery and returns to normal message processing. (But
note that no skipping occurs if an error is detected while processing Sync
— this ensures that there is one and only one ReadyForQuery sent for each
Sync.)
"""

This paragraph acknowledges that an error can be "detected" while
processing a Sync, but one reading of it might suggest that the only
response from a Sync is a single ReadyForQueryMessage.

Thanks!

- Andrei

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vladimir Sitnikov 2022-01-12 18:03:17 Re: is ErrorResponse possible on Sync?
Previous Message Bossart, Nathan 2022-01-12 17:25:55 Re: do only critical work during single-user vacuum?