go-mysql-org/go-mysql

How to use TRANSACTION_CONTEXT_EVENT for the replication

zhanghaiyang9999 opened this issue · 2 comments

When using the following code, how to detect what's is the transaction begin(if a transaction has multiple operations) ? is the TRANSACTION_CONTEXT_EVENT ? thanks!

streamer, err := syncer.StartSync(pos)
contx, cancel := context.WithTimeout(context.Background(), time.Second)
ev, err := streamer.GetEvent(contx)

it depends on your mysql version. you can dump every events to log and find the pattern. for some mysql version, I remember there are "BEGIN" query events for each transaction.

If you have GTID enabled, GTID_event is the beginning of the transaction and Xid_event is the end of the transaction.