mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Log the conflicts while applying changes in logical replication.
This patch provides the additional logging information in the following conflict scenarios while applying changes: insert_exists: Inserting a row that violates a NOT DEFERRABLE unique constraint. update_differ: Updating a row that was previously modified by another origin. update_exists: The updated row value violates a NOT DEFERRABLE unique constraint. update_missing: The tuple to be updated is missing. delete_differ: Deleting a row that was previously modified by another origin. delete_missing: The tuple to be deleted is missing. For insert_exists and update_exists conflicts, the log can include the origin and commit timestamp details of the conflicting key with track_commit_timestamp enabled. update_differ and delete_differ conflicts can only be detected when track_commit_timestamp is enabled on the subscriber. We do not offer additional logging for exclusion constraint violations because these constraints can specify rules that are more complex than simple equality checks. Resolving such conflicts won't be straightforward. This area can be further enhanced if required. Author: Hou Zhijie Reviewed-by: Shveta Malik, Amit Kapila, Nisha Moond, Hayato Kuroda, Dilip Kumar Discussion: https://postgr.es/m/OS0PR01MB5716352552DFADB8E9AD1D8994C92@OS0PR01MB5716.jpnprd01.prod.outlook.com
This commit is contained in:
58
src/include/replication/conflict.h
Normal file
58
src/include/replication/conflict.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
* conflict.h
|
||||
* Exports for conflicts logging.
|
||||
*
|
||||
* Copyright (c) 2024, PostgreSQL Global Development Group
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef CONFLICT_H
|
||||
#define CONFLICT_H
|
||||
|
||||
#include "nodes/execnodes.h"
|
||||
#include "utils/timestamp.h"
|
||||
|
||||
/*
|
||||
* Conflict types that could occur while applying remote changes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* The row to be inserted violates unique constraint */
|
||||
CT_INSERT_EXISTS,
|
||||
|
||||
/* The row to be updated was modified by a different origin */
|
||||
CT_UPDATE_DIFFER,
|
||||
|
||||
/* The updated row value violates unique constraint */
|
||||
CT_UPDATE_EXISTS,
|
||||
|
||||
/* The row to be updated is missing */
|
||||
CT_UPDATE_MISSING,
|
||||
|
||||
/* The row to be deleted was modified by a different origin */
|
||||
CT_DELETE_DIFFER,
|
||||
|
||||
/* The row to be deleted is missing */
|
||||
CT_DELETE_MISSING,
|
||||
|
||||
/*
|
||||
* Other conflicts, such as exclusion constraint violations, involve more
|
||||
* complex rules than simple equality checks. These conflicts are left for
|
||||
* future improvements.
|
||||
*/
|
||||
} ConflictType;
|
||||
|
||||
extern bool GetTupleTransactionInfo(TupleTableSlot *localslot,
|
||||
TransactionId *xmin,
|
||||
RepOriginId *localorigin,
|
||||
TimestampTz *localts);
|
||||
extern void ReportApplyConflict(EState *estate, ResultRelInfo *relinfo,
|
||||
int elevel, ConflictType type,
|
||||
TupleTableSlot *searchslot,
|
||||
TupleTableSlot *localslot,
|
||||
TupleTableSlot *remoteslot,
|
||||
Oid indexoid, TransactionId localxmin,
|
||||
RepOriginId localorigin, TimestampTz localts);
|
||||
extern void InitConflictIndexes(ResultRelInfo *relInfo);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user