Re: Removing support for FE/BE protocol version 2

From: Nadav Shatz <nadav(at)tailorbrands(dot)com>
To: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Cc: pgpool-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Removing support for FE/BE protocol version 2
Date: 2026-10-02 12:20:56
Message-ID: CACeKOO073LF3VPNh0F-PCn+e_UZTQSoCJBFSO_DLu6vY3NvG6w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-hackers

Thanks for working on this. +1 for removing v2 in 4.8.

Some comments on v1:

0001:

- pool_error_code("0X000") looks like a typo. ERRCODE_FEATURE_NOT_SUPPORTED
is "0A000".

- PostgreSQL's message for this case is "unsupported frontend protocol
%u.%u: server supports %u.0 to %u.%u". If the goal is the same
behavior as PostgreSQL, maybe we could use the same text.

- The "break;" after ereport(FATAL) is unreachable (minor).

0002:

- There is a stray blank line after "/* Send each field */" in
cache_reporting().

> I plan to work on rest of source files that handle the v2 protocol.
>
> src/auth/pool_auth.c
> src/auth/pool_hba.c
> src/context/pool_query_context.c
> src/protocol/pool_process_query.c
> src/protocol/pool_proto_modules.c
> src/query_cache/pool_memqcache.c
> src/streaming_replication/pool_worker_child.c
> src/test/regression/tests/010.rewrite_timestamp/timestamp/main.c
> src/utils/error/elog.c
>
> I hope I am not missing anything...

About elog.c: I think we should keep the v2 branch in
send_message_to_frontend(), or at least a minimal version of it.
With 0001, child_frontend->protoVersion is already 2 when the FATAL
is raised, so the error goes out in the old "E<text>\n" format. That
is what a v2 client can understand. PostgreSQL 14+ kept the old-style
error output for this same reason. If we remove it, the client gets a
v3 ErrorResponse it can't parse.

Some more places not on the list:

- src/protocol/pool_proto2.c: the whole file is v2 only (AsciiRow,
BinaryRow, CursorResponse, CompletedResponse, ErrorResponse,
NoticeResponse, NotificationResponse, FunctionResultResponse,
RowDescription, EmptyQueryResponse). It can be removed together with
its entry in src/Makefile.am and the prototypes in
src/include/protocol/pool_proto_modules.h. The callers are in
pool_proto_modules.c, which is already on your list.

- src/include/pool.h: StartupPacket_v2 (and PROTO_MAJOR_V2 once
nothing else uses it).

- src/tools/pgindent/typedefs.list: the StartupPacket_v2 entry.

- src/protocol/child.c: some v2 code is left besides
read_startup_packet(), e.g. around line 1932:
"(sp->major == PROTO_MAJOR_V3) ? "08S01" : NULL".

After all this, MAJOR() always returns 3, so the protoMajor argument of
do_query(), do_command(), pool_send_error_message(),
pool_send_fatal_message(), pool_send_severity_message(), pool_get_cp()
and pool_discard_cp() becomes unused, as does
session_context->major/pool_get_major_version(). Same for the backend
argument of the reporting functions after 0002. Removing those touches
many call sites, so a separate patch at the end of the series is
probably better.

Two more things:

- A regression test that sends a v2 startup packet and checks that we
get the FATAL error. It's small, and it covers the only v2 code path
we keep.

- An incompatibility item in the 4.8 release notes.

Thanks,

On Fri, Oct 2, 2026 at 1:41 PM Tatsuo Ishii <ishii(at)postgresql(dot)org> wrote:

> > PostgreSQL 14, which was released in 2021, removed protocol version 2
> > support. The last version supporting protocol version 2 was 13, which
> > was EOLed in November 2025. So, existing supported PostgreSQL versions
> > do not accept the protocol version 2 anymore (more precisely, they
> > response with "unsupported protocol version" error when the protocol
> > is requested).
> >
> > I would like to propose removing support for FE/BE protocol version 2
> > in upcoming v4.8. If the version 2 startup message arrives, pgpool
> > responds with "unsupported protocol version" error, which is the same
> > behavior as PostgreSQL server.
> >
> > The merits of dropping v2 protocol are:
> >
> > - Simplifying our code base. There are pretty large number of code
> > path which handles v2 protocol.
> >
> > - Removing untested codes. Our regression tests do not include v2
> > protocol cases.
> >
> > We cannot support the version 2 protocol forever. Dropping it is only
> > a matter of time. As I already mentioned above, all supported
> > PostgreSQL versions finally drop the v2 protocol, I think v4.8 is the
> > good timing to remove v2 protocol for us.
> >
> > Thoughts?
>
> 3 months ago I posted this message and haven't seen any
> replies. Assuming no objection, I have started to work on
> this. Attached are the in progress patch sets.
>
> 001 is to reject the v2 protocol startup packet. If v2 frontend
> connects, raise a FATAL error.
>
> 002 is to remove v2 protocol processing in process reporting modules
> (e.g. show pool_nodes).
>
> I plan to work on rest of source files that handle the v2 protocol.
>
> src/auth/pool_auth.c
> src/auth/pool_hba.c
> src/context/pool_query_context.c
> src/protocol/pool_process_query.c
> src/protocol/pool_proto_modules.c
> src/query_cache/pool_memqcache.c
> src/streaming_replication/pool_worker_child.c
> src/test/regression/tests/010.rewrite_timestamp/timestamp/main.c
> src/utils/error/elog.c
>
> I hope I am not missing anything...
>
> Regards,
> --
> Tatsuo Ishii
> SRA OSS K.K.
> English: http://www.sraoss.co.jp/index_en/
> Japanese:http://www.sraoss.co.jp
>

--
Nadav Shatz
Tailor Brands | CTO

In response to

Responses

Browse pgpool-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-10-02 13:21:27 Re: Removing support for FE/BE protocol version 2
Previous Message Tatsuo Ishii 2026-10-02 11:41:18 Re: Removing support for FE/BE protocol version 2