Make the logical replication conflict messages more like each other

Started by Peter Smith6 months ago4 messageshackers

Thread notes

1 note#feature#minor#enhancement
hackorum-bot#feature#minor#enhancement
hackorum-bot
2 days ago

@global #feature #minor #enhancement

#feature#minor#enhancement
Jump to latest
#1Peter Smith
smithpb2250@gmail.com

Hi,

(This was first suggested by me in thread [1]/messages/by-id/CAHut+PvicB-bAqo4XpsPOnr=Li_jop6i4kpcy+VK_MYsEFFeqg@mail.gmail.com, but it was deemed out
of scope, so I have now separated it here.)

I was looking at the many messages related to logical replication
conflicts (in conflict.c, function errdetail_apply_conflict).
Currently, the wording for the errmsgdetail seems a bit inconsistent
to me. I felt that because all of these messages are closely related,
they should all resemble each other more than they do now.

~~~

CURRENT

CT_INSERT_EXISTS
CT_UPDATE_EXISTS
CT_MULTIPLE_UNIQUE_CONFLICTS
* Could not apply remote change: %s.\n
* Could not apply remote change.\n
- Key already exists in unique index \"%s\", modified locally in
transaction %u at %s: %s.
- Key already exists in unique index \"%s\", modified locally in
transaction %u at %s.
- Key already exists in unique index \"%s\", modified by origin \"%s\"
in transaction %u at %s: %s.
- Key already exists in unique index \"%s\", modified by origin \"%s\"
in transaction %u at %s.
- Key already exists in unique index \"%s\", modified by a
non-existent origin in transaction %u at %s: %s.
- Key already exists in unique index \"%s\", modified by a
non-existent origin in transaction %u at %s.
- Key already exists in unique index \"%s\", modified in transaction %u: %s.
- Key already exists in unique index \"%s\", modified in transaction %u.

CT_UPDATE_ORIGIN_DIFFERS
- Updating the row that was modified locally in transaction %u at %s: %s.
- Updating the row that was modified locally in transaction %u at %s.
- Updating the row that was modified by a different origin \"%s\" in
transaction %u at %s: %s.
- Updating the row that was modified by a different origin \"%s\" in
transaction %u at %s.
- Updating the row that was modified by a non-existent origin in
transaction %u at %s: %s.
- Updating the row that was modified by a non-existent origin in
transaction %u at %s.

CT_UPDATE_DELETED
* Could not find the row to be updated: %s.\n
* Could not find the row to be updated.\n
- The row to be updated was deleted locally in transaction %u at %s
- The row to be updated was deleted by a different origin \"%s\" in
transaction %u at %s
- The row to be updated was deleted by a non-existent origin in
transaction %u at %s
- The row to be updated was deleted

CT_UPDATE_MISSING
* Could not find the row to be updated: %s.
* Could not find the row to be updated.

CT_DELETE_ORIGIN_DIFFERS
- Deleting the row that was modified locally in transaction %u at %s: %s.
- Deleting the row that was modified locally in transaction %u at %s.
- Deleting the row that was modified by a different origin \"%s\" in
transaction %u at %s: %s.
- Deleting the row that was modified by a different origin \"%s\" in
transaction %u at %s.
- Deleting the row that was modified by a non-existent origin in
transaction %u at %s: %s.
- Deleting the row that was modified by a non-existent origin in
transaction %u at %s.

CT_DELETE_MISSING
* Could not find the row to be deleted: %s.
* Could not find the row to be deleted.

~~~

Some proposed changes:
e.g. Only some cases (CT_UPDATE_DELETED, CT_INSERT_EXISTS,
CT_UPDATE_EXISTS, etc.) currently give the general reason, followed on
the next line by the details for the conflict. I think all these
conflict messages should use this pattern
e.g. All errdetail messages should have a period to terminate them.
e.g. Use more consistent wording for all conflicts: "The row to
update", "The row to delete", etc.
e.g. The words "the row to be updated" do not need to be repeated for
the same conflict message.
e.g. The suggested wording makes the messages much closer to the DOCS
[2]: https://www.postgresql.org/docs/devel/logical-replication-conflicts.html

(Compare the CURRENT messages above with the following SUGGESTIONS below)

SUGGESTIONS (or something like this...)

CT_INSERT_EXISTS
CT_UPDATE_EXISTS
CT_MULTIPLE_UNIQUE_CONFLICTS
* The row to insert violates a constraint: %s.\n
* The row to insert violates a constraint.\n
* The row to update violates a constraint: %s.\n
* The row to update violates a constraint.\n
* The row to insert or update violates a constraint: %s.\n
* The row to insert or update violates a constraint.\n
- Key already exists in unique index \"%s\", modified locally in
transaction %u at %s: %s.
- Key already exists in unique index \"%s\", modified locally in
transaction %u at %s.
- Key already exists in unique index \"%s\", modified by origin \"%s\"
in transaction %u at %s: %s.
- Key already exists in unique index \"%s\", modified by origin \"%s\"
in transaction %u at %s.
- Key already exists in unique index \"%s\", modified by a
non-existent origin in transaction %u at %s: %s.
- Key already exists in unique index \"%s\", modified by a
non-existent origin in transaction %u at %s.
- Key already exists in unique index \"%s\", modified in transaction %u: %s.
- Key already exists in unique index \"%s\", modified in transaction %u.

CT_UPDATE_ORIGIN_DIFFERS
* The row to update was modified by another origin.\n
- It was modified locally in transaction %u at %s: %s.
- It was modified locally in transaction %u at %s.
- It was modified by a different origin \"%s\" in transaction %u at %s: %s.
- It was modified by a different origin \"%s\" in transaction %u at %s.
- It was modified by a non-existent origin in transaction %u at %s: %s.
- It was modified by a non-existent origin in transaction %u at %s.

CT_UPDATE_DELETED
* The row to update was already deleted: %s.\n
* The row to update was already deleted.\n
- It was deleted locally in transaction %u at %s.
- It was deleted by a different origin \"%s\" in transaction %u at %s.
- It was deleted by a non-existent origin in transaction %u at %s.

CT_UPDATE_MISSING
* The row to update was not found: %s.
* The row to update was not found.

CT_DELETE_ORIGIN_DIFFERS
* The row to delete was modified by another origin.\n
- It was modified locally in transaction %u at %s: %s.
- It was modified locally in transaction %u at %s.
- It was modified by a different origin \"%s\" in transaction %u at %s: %s.
- It was modified by a different origin \"%s\" in transaction %u at %s.
- It was modified by a non-existent origin in transaction %u at %s: %s.
- It was modified by a non-existent origin in transaction %u at %s.

CT_DELETE_MISSING
* The row to delete was not found: %s.
* The row to delete was not found.

~~~

Anyway, this is just a suggestion. I won't make the patch for this
unless/until there is agreement that proceeding would be worthwhile.

======
[1]: /messages/by-id/CAHut+PvicB-bAqo4XpsPOnr=Li_jop6i4kpcy+VK_MYsEFFeqg@mail.gmail.com
[2]: https://www.postgresql.org/docs/devel/logical-replication-conflicts.html

Kind Regards,
Peter Smith.
Fujitsu Australia.

#2Peter Smith
smithpb2250@gmail.com
In reply to: Peter Smith (#1)
Re: Make the logical replication conflict messages more like each other

Ping. This thread is now a month old with no replies... Any feedback?

======
Kind Regards,
Peter Smith.
Fujitsu Australia

#3Peter Smith
smithpb2250@gmail.com
In reply to: Peter Smith (#2)
Re: Make the logical replication conflict messages more like each other

On Mon, Jun 29, 2026 at 2:20 PM Peter Smith <smithpb2250@gmail.com> wrote:

Ping. This thread is now a month old with no replies... Any feedback?

Have added a CF entry for this [1]https://commitfest.postgresql.org/patch/7043/

======
[1]: https://commitfest.postgresql.org/patch/7043/

Kind Regards,
Peter Smith
Fujitsu Australia

#4Ajin Cherian
itsajin@gmail.com
In reply to: Peter Smith (#1)
Re: Make the logical replication conflict messages more like each other

On Tue, May 19, 2026 at 9:08 AM Peter Smith <smithpb2250@gmail.com> wrote:

Hi,

(This was first suggested by me in thread [1], but it was deemed out
of scope, so I have now separated it here.)

I was looking at the many messages related to logical replication
conflicts (in conflict.c, function errdetail_apply_conflict).
Currently, the wording for the errmsgdetail seems a bit inconsistent
to me. I felt that because all of these messages are closely related,
they should all resemble each other more than they do now.

~~~

Hi Peter,

Just want to +1 the general idea here. Consistency across these
conflict messages is worth caring about - it helps users pattern-match
on wording in logs. It also makes it easier for whoever adds a new
conflict type later to slot into an existing style rather than
drifting further apart.

regards,
Ajin Cherian
Fujitsu Australia