- Newest
- Most votes
- Most comments
Based on the behavior you're describing, this appears to be related to how logical replication handles INSERT ON CONFLICT statements in Aurora PostgreSQL, rather than a bug with the statement itself.
When using logical replication with subscriptions, there's a known limitation where the ON CONFLICT clause isn't fully supported in certain contexts. Native PostgreSQL logical replication can't detect data conflicts from multiple publishers or replicated modifications that conflict with locally changed data. When replication workers process changes, they may log errors even when the underlying operation completes successfully.
The fact that your INSERT is succeeding in the background while generating error logs is consistent with how logical replication handles conflict scenarios. The replication process attempts to apply the change, encounters what it perceives as a conflict situation, logs the error, but the actual data operation may still complete through PostgreSQL's normal conflict resolution mechanisms.
A few points to consider:
-
The error logging behavior in logical replication contexts can differ from direct SQL execution, which explains why you don't see this error when testing locally outside of a replication scenario.
-
The disable_on_error flag may not trigger for this specific type of logged error if the underlying transaction ultimately succeeds, which aligns with your observation that replication continues working.
-
The error message about "no unique or exclusion constraint matching the ON CONFLICT specification" in the logs may be generated during the replication worker's processing phase, even though the constraint exists and works correctly for direct operations.
To work around this, you might consider restructuring your trigger logic to handle potential conflicts differently, or review whether the logical replication setup requires adjustments to how conflicts are managed. You could also check the PostgreSQL logs for more detailed context about when these errors occur in relation to the replication worker processes.
Sources
Troubleshoot Aurora PostgreSQL logical replication issues | AWS re:Post
Aurora PostgreSQL-Compatible integration with remote PostgreSQL databases - AWS Prescriptive Guidance
