| From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
|---|---|
| To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
| Cc: | shveta malik <shveta(dot)malik(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, Doruk Yilmaz <doruk(at)mixrank(dot)com> |
| Subject: | Re: [Patch] add new parameter to pg_replication_origin_session_setup |
| Date: | 2026-02-03 19:08:21 |
| Message-ID: | e0508305-bc6a-417c-b969-36564d632f9e@iki.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
The new error message is not great:
postgres=# select pg_replication_origin_session_setup('myorigin', 12345678);
ERROR: could not find replication state slot for replication origin
with OID 1 which was acquired by 12345678
Firstly, replication origin is not an OID. Secondly, it's a little
confusing because the "replication state slot" is in fact present.
However, it's currently inactive, i.e. not "acquired" by the given PID.
I propose to change that to:
postgres=# select pg_replication_origin_session_setup('myorigin', 12345678);
ERROR: replication origin with ID 1 is not active for PID 12345678
That's more in line with this neighboring message:
ERROR: replication origin with ID 1 is already active for PID 701228
I also wonder if the error code is appropriate. That error uses
ERRCODE_OBJECT_IN_USE, but if the problem is that the origin is
currently *not* active, that seems backwards. I didn't change that in
the attached patch, but it's something to think about.
The second patch rearranges the if-else statements to check those
conditions. I found the current logic hard to follow, this makes them
feel more natural, in my opinion at least. It has one user-visible
effect: If you call the function with acquired_pid != 0 and the origin
has no state slot, *and* there are no free slots, you previously got
this error:
postgres=# select pg_replication_origin_session_setup('other', 123);
ERROR: could not find free replication state slot for replication
origin with ID 2
HINT: Increase "max_active_replication_origins" and try again.
Now you get this:
postgres=# select pg_replication_origin_session_setup('other', 123);
ERROR: cannot use PID 123 for inactive replication origin with ID 2
Both error messages are more or less appropriate in that situation, but
I think the new behavior is slightly better. The fact that the origin is
inactive feels like the bigger problem here.
- Heikki
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Improve-error-message.patch | text/x-patch | 1.1 KB |
| 0002-Rearrange-the-checks-in-replorigin_session_setup.patch | text/x-patch | 4.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Mahendra Singh Thalor | 2026-02-03 19:14:37 | Re: getting "shell command argument contains a newline or carriage return:" error with pg_dumpall when db name have new line in double quote |
| Previous Message | Andreas Karlsson | 2026-02-03 19:04:31 | Re: GSoC 2026: Call for Mentors, Project Ideas and Project Idea Reviews |