I successfully installed Postgres Debezium CDC
. Now, I'm able to catch all changes happening to the database. But the problem is "before" field always stays empty. So, if I insert a record (id = 1, name = Bill)
I then get from Kafka this data:
'payload': {'before': None, 'after': {'id': 1, 'name': 'Bill'}, ...
But if I update the record like so:
UPDATE mytable set name = 'Bob' WHERE id = 1
I get this from Kafka:
'payload': {'before': None, 'after': {'id': 1, 'name': 'Bob'}, ...
This is how I configured my connector:
curl -X POST localhost:8083/connectors/ \
-H "Accept:application/json" -H "Content-Type:application/json" -d \
'{
"name": "test-connector",
"config": {
"connector.class": "io.debezium.connector.postgresql.PostgresConnector",
"tasks.max": "1",
"plugin.name": "pgoutput",
"database.hostname": "postgres",
"database.port": "5432",
"database.user": "postgres",
"database.password": "postgres",
"database.dbname" : "test",
"database.server.name": "postgres",
"database.whitelist": "public.mytable",
"database.history.kafka.bootstrap.servers": "kafka:9092",
"database.history.kafka.topic": "public.topic"
}
}'
What is wrong with that and how can I fix it?
before
property is None (in Python) or null (in PHP). – Bacitracin'payload': {'before': None, 'after': {'id': 1, 'name': 'Bob'}
is about update event and not about the insert event that you read again? Please show more data in messages – Laywoman$topic->consumeStart(0, RD_KAFKA_OFFSET_BEGINNING);
. And I'm totally sure, that the message withname: Bob
is an update event, because it pops up, when I manually executeUPDATE
statement. – Bacitracinid
field is serial, so it's impossible to have two records withid = 1
– BacitracinREPLICA IDENTITY for 'registry.schema_version' is 'DEFAULT'; UPDATE and DELETE events will contain previous values only for PK columns
. It seems like this is the whole problem, but I'm not sure how to fix it. – BacitracinALTER TABLE public.mytable REPLICA IDENTITY FULL;
– Laywoman