Getting row xmin for snapshot messages with Postgres connector

68 views
Skip to first unread message

David Breton

unread,
Sep 26, 2023, 1:03:01 PM9/26/23
to debezium
I am using version 2.3.4 and I'm trying to include the PG *row* xmin (not the *replication slot* xmin) for every message produced during the snapshot (op=r). Those messages include source.txId with the id of the 'READ transaction' that was used by the snapshot to read the DB, that is not the transaction id I am after, I want to know the id of the transaction that caused the last update on the row (before the snapshot). I can get that value with a query like "SELECT xmin,* FROM ...".

I tried putting xmin in the "column.include.list" but it didn't work, next I wrote a custom snapshotter that includes this:


@Override
public Optional<String> buildSnapshotQuery(TableId tableId, List<String> snapshotSelectColumns) {
String query = snapshotSelectColumns.stream()
.collect(Collectors.joining(", ", "SELECT xmin,", " FROM " + tableId.toDoubleQuotedString()));

return Optional.of(query);
}

When I started the connector I got a message like this:

java.lang.IllegalArgumentException: Column 'xmin' not found in result set 'xmin, id, createdAt, updatedAt, placeCategoryTypeName, ...'

This was followed by a list of all the columns in the table omitting the xmin "system column". So it seems that the xmin system column is fetched from PG (because it is part of the result set) but then it is cross-referenced against the non-system column names and this is what causes the error.

Is there any way I can get the xmin value included for the snapshot messages?


jiri.p...@gmail.com

unread,
Sep 27, 2023, 5:01:59 AM9/27/23
to debezium
Hi,

this is definitely good requirement but it is not achievable without changes to the Debezium codebase.

J.

David Breton

unread,
Sep 27, 2023, 1:31:28 PM9/27/23
to debezium
I had a look at the Debezium codebase and came to the same conclusion. Thank you for confirming.

David

Reply all
Reply to author
Forward
0 new messages