go-mysql-org / go-mysql

a powerful mysql toolset with Go
MIT License
4.52k stars 967 forks source link

help to understand why do we dump some data first before sync the data from binlog #855

Closed amitiwary999 closed 3 months ago

amitiwary999 commented 3 months ago

I was going through the repo code and had one doubt. In the binlogsyncer file the StartSync function is the entry point. I checked the code in this function and reached the function writeBinlogDumpCommand. This is used to write some data to a binlog file. Can anyone please help me to understand what we dump here and why?

lance6716 commented 3 months ago

it follows the MySQL replication protocol https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_replication.html https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_binlog_dump.html

amitiwary999 commented 3 months ago

Thank you @lance6716 . So this is use to request binlog data from mysql. Once connection is established and COM_BINLOG_DUMP command is sent we start getting the data continuously from the bingo file from the provided start position?

lance6716 commented 3 months ago

yes it's decribed in the doc

Network streams are requested with COM_BINLOG_DUMP and prepend each Binlog Event with 00 OK-byte.

amitiwary999 commented 3 months ago

Thanks.

On Mon, Apr 8, 2024, 19:11 lance6716 @.***> wrote:

yes it's decribed in the doc

Network streams are requested with COM_BINLOG_DUMP https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_binlog_dump.html and prepend each Binlog Event https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_replication_binlog_event.html with 00 OK-byte.

— Reply to this email directly, view it on GitHub https://github.com/go-mysql-org/go-mysql/issues/855#issuecomment-2042793599, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADK2YLDOJOCMLKOQYN7EOOLY4KNAHAVCNFSM6AAAAABF4WB5COVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBSG44TGNJZHE . You are receiving this because you authored the thread.Message ID: @.***>