Hello all, if Flink uses JDBC to write to TiDB are...
# random
s
Hello all, if Flink uses JDBC to write to TiDB are multiple insert DDL in the one transaction? Because the follow-up Ticdc don't capture the changelog completely.
m
I don't think that the JDBC connector supports TiDB at this moment?
s
TiDB is highly compatible with the MySQL protocol, so can connect using JDBC.
m
But still, from a Flink POV, there's never been any testing done to see if it works with TiDB
Which API of Flink are you using?
s
I have successfully used JDBC to insert data to tidb, but there will be multiple inserts for the same primary key data in one transaction
I use flink sql jdbc connector
What I want to find out is whether it is the mechanism of flink itself or tidb. I am asking questions at the same time in the communities on both sides.
m
How can there be multiple inserts for the same primary key from a Flink perspective?
s
m
You have one incoming record/event and you're writing that to a JDBC sink. I'm assuming you have set up a primary key in your Flink table definition, so it operates in upsert mode, right?
s
yes
m
Yes, so when you have one incoming record/event, you have a primary key defined in your table DDL and you're writing that to a MySQL database, Flink will use
INSERT .. ON DUPLICATE KEY UPDATE ..
under the hood when writing to MySQL
But there won't be multiple insert ~DDLs~: DML every incoming record/event will be posted as
INSERT .. ON DUPLICATE KEY UPDATE ..
s
one record one DDL?
m
Sorry, meant DML, not DDL
s
yes, DML
I have set sink.buffer-flush.interval='0'/sink.buffer-flush.max-rows='0' to disable the batch sink, but there are still multiple DMLs in one transaction, which does not seem to be the mechanism of flink itself?
m
I'm under the impression that Flink will send multiple
INSERT .. ON DUPLICATE KEY UPDATE ..
- As far as I know, there's no transaction support anyway for Flink SQL (only in the DataStream API)
s
Ok, thanks for your help, I will ask the tidb community.