Re: Inconsistent error handling in START_REPLICATION command

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Inconsistent error handling in START_REPLICATION command
Дата
Msg-id CAMsr+YH=Ni42okN5HsTpVp=DHzHYFGjn4SL8EQHFh_pXWYZA9Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Inconsistent error handling in START_REPLICATION command  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers
On 20 January 2016 at 15:28, Craig Ringer <craig@2ndquadrant.com> wrote:

For that reason I'd actually like to enter COPY BOTH mode before the startup callback, as is currently the case. So I'd like to wrap the decoding startup callback in a PG_TRY that catches an ERROR raised by the startup callback (if any) and exits COPY BOTH mode before re-throwing.

 
I hoped this'd be as simple as:

      PG_TRY();
      {
          logical_decoding_ctx = CreateDecodingContext(
                                                     cmd->startpoint, cmd->options,
                                                       logical_read_xlog_page,
                                              WalSndPrepareWrite, WalSndWriteData);
      }
      PG_CATCH();
      {
          pq_putmessage_noblock('c', NULL, 0);
          pq_flush();
          PG_RE_THROW();
      }
      PG_END_TRY();
  

but that's doesn't look sufficient, presumably as the client never has a chance to ack the exit from CopyBoth mode. Or maybe libpq just isn't prepared to cope with existing COPY then immediately getting an error.

What you have now works and fixes the immediate problem. Preserving the early start of COPY mode isn't actually useful until we're also prepared to accept writes from the output plugin's startup callback at that point, which we are not yet.

Maybe we should just apply your patch as-is, then move the start of COPY back if/when support for emitting output from within a logical decoding startup callback gets added.


--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Vladimir Sitnikov
Дата:
Сообщение: Set search_path + server-prepared statements = cached plan must not change result type
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: Stream consistent snapshot via a logical decoding plugin as a series of INSERTs