pingcap / tidb-binlog

A tool used to collect and merge tidb's binlog for real-time data backup and synchronization.
Apache License 2.0
292 stars 131 forks source link

Out of order Binlog Item #734

Closed thuyenptr closed 5 years ago

thuyenptr commented 5 years ago

Hi,

First, I'm sorry because I'm asking too much, but currently, I'm curious about the mechanism of TiDB-Binlog deeply.

When I read the code, I'm very confused about how drainer guarantees the order of Binlogs, in this situation:

binlog-failure

When the maxCommitTS of 2 pump instance different, in this picture you can see PullBinlog pull all Binlog from last=3 to maxCommitTS of each pump instance and then transfer Binlog to Merger. After that Merger gets min Binlog and Add(item) to Syncer. When Drainer calls PullBinlog again (interval = 10 seconds), unfortunately, Pump is resolving item at start_ts = 5, and pump2 working normally, and then I lose the order Binlog item (5,7,9,11).

Can you explain this situation to me? Thank you.

thuyenptr commented 5 years ago

Tag: @july2993, please.

july2993 commented 5 years ago

you are welcome to ask any question. sorry for not quite so understand your problem, what do you means "resolving item at start_ts = 5".

if it can't get any item from a pump, it will block to output data to downstream because it can't know which one is the minimum one.

thuyenptr commented 5 years ago

"resolving item at start_ts = 5", I mean sorter will try to resolve Commit Binlog correspond with Prewrite Binlog (confirm commit_ts from TiKV).

You say: "if it can't get any item from a pump, it will block to output data to downstream", can you show me where the code says "block to output data to downstream"?. I can see in this code, skip nil source, but this still got items from any available source

july2993 commented 5 years ago

look like this https://github.com/pingcap/tidb-binlog/blob/72d76d6793583567ae78d7a027738ac0542db8c1/drainer/merge.go#L290 ?

thuyenptr commented 5 years ago

Thank you for your support. I understood that concept.