From 58c0291b7aa97dc2ec98857000c3c44d7b998602 Mon Sep 17 00:00:00 2001 From: starainrt Date: Mon, 3 Jul 2023 15:45:54 +0800 Subject: [PATCH] bug fix --- parse.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/parse.go b/parse.go index 4bb417a..d3337d8 100644 --- a/parse.go +++ b/parse.go @@ -42,6 +42,8 @@ type Transaction struct { Size int `json:"size"` RowsCount int `json:"rowsCount"` Status uint8 `json:"status"` + TxStartTime int64 `json:"txStartTime"` + TxEndTime int64 `json:"txEndTime"` sqlOrigin []string `json:"sqlOrigin"` Txs []TxDetail `json:"txs"` validSchemaCount int @@ -611,11 +613,16 @@ func parseBinlogWithFilter(r io.Reader, parse *replication.BinlogParser, filter if ev.Type == "query" { switch strings.ToLower(ev.Data) { case "begin": + if tx.TxStartTime == 0 { + tx.TxStartTime = int64(h.Timestamp) + } status = STATUS_BEGIN case "commit": status = STATUS_COMMIT + tx.TxEndTime = int64(h.Timestamp) case "rollback": status = STATUS_ROLLBACK + tx.TxEndTime = int64(h.Timestamp) } tx.Status = status }