背景
在测试和生产部署了canal,监听同一个服务的同一个表,比如a服务的b表,不过一个测试一个生产环境,然后canal传给kafka,最后由开发读取kafka。当发生update操作时,测试环境传递的before字段有值,生产before字段没有值
update传递的字段
before字段是记录修改之前的记录,正常来讲是有的
{
"database":"",
"table":"",
"event_data":[
{
"before":{
},
"after":{
"account_id":118392114,
"agency_task_id":1397,
"status":"employed",
"create_time":"2021-08-18 17:03:50",
"update_time":"2021-09-18 12:43:55",
"remark":null,
"voice_url":"",
"voice_duration":369,
"reason":"",
"solution":"",
"examine_record":"[{\"state\": \"undetermined\", \"account_id\": 118197936}, {\"state\": \"employed\", \"account_id\": 118197936}]"
},
"event_type":"UPDATE"
}
],
"before":{
},
"after":{
"account_id":118392114,
"agency_task_id":1397,
"status":"employed",
"create_time":"2021-08-18 17:03:50",
"update_time":"2021-09-18 12:43:55",
"remark":null,
"voice_url":"",
"voice_duration":369,
"reason":"",
"solution":"",
"examine_record":"[{\"state\": \"undetermined\", \"account_id\": 118197936}, {\"state\": \"employed\", \"account_id\": 118197936}]"
},
"type":"UPDATE",
"ts":1631940235565
}
解决
-
对比了测试和生产数据库的配置,发现binlog_row_image的设置不同,测试设置为FULL,生产设置为minimal
-
差别可以看上面链接,最后修改为FULL解决