Skip to content

Commit 5e0be80

Browse files
author
ffffwh
committed
add logs
- info 'applier tx committed' if env set - docker run -e DTLE_LOG_TX_COMMIT=1 actiontech/dtle - detail: unexpected error on publish
1 parent 1204ded commit 5e0be80

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

driver/mysql/applier_incr.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ type ApplierIncr struct {
7171
sourceType string
7272
tableSpecs []*common.TableSpec
7373

74-
inBigTx bool
74+
inBigTx bool
75+
logTxCommit bool
7576
}
7677

7778
func NewApplierIncr(applier *Applier, sourcetype string) (*ApplierIncr, error) {
@@ -99,6 +100,10 @@ func NewApplierIncr(applier *Applier, sourcetype string) (*ApplierIncr, error) {
99100
a.SkipGtidExecutedTable = true
100101
}
101102

103+
if g.EnvIsTrue(g.ENV_DTLE_LOG_TX_COMMIT) {
104+
a.logTxCommit = true
105+
}
106+
102107
a.timestampCtx = NewTimestampContext(a.shutdownCh, a.logger, func() bool {
103108
return len(a.binlogEntryQueue) == 0 && len(a.applyBinlogMtsTxQueue) == 0
104109
// TODO need a more reliable method to determine queue.empty.
@@ -732,7 +737,11 @@ func (a *ApplierIncr) ApplyBinlogEvent(workerIdx int, binlogEntryCtx *common.Ent
732737
if a.printTps {
733738
atomic.AddUint32(&a.txLastNSeconds, 1)
734739
}
735-
logger.Debug("applier tx committed", "gno", binlogEntry.Coordinates.GetGNO())
740+
if a.logTxCommit {
741+
logger.Info("applier tx committed", "gno", binlogEntry.Coordinates.GetGNO())
742+
} else {
743+
logger.Debug("applier tx committed", "gno", binlogEntry.Coordinates.GetGNO())
744+
}
736745
atomic.AddUint32(&a.appliedTxCount, 1)
737746
}
738747
a.EntryExecutedHook(binlogEntry)

driver/mysql/extractor.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,8 @@ func (e *Extractor) publish(subject string, txMsg []byte, gno int64) (err error)
11041104
e.logger.Debug("publish", "subject", subject, "gno", gno, "partLen", len(part), "iSeg", iSeg)
11051105
_, err := e.natsConn.Request(subject, part, 24*time.Hour)
11061106
if err != nil {
1107-
e.logger.Error("unexpected error on publish", "err", err)
1107+
e.logger.Error("unexpected error on publish", "err", err,
1108+
"subject", subject, "gno", gno, "partLen", len(part), "iSeg", iSeg)
11081109
return err
11091110
}
11101111
}

g/g.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@ const (
3535

3636
JobNameLenLimit = 64
3737

38-
ENV_PRINT_TPS = "UDUP_PRINT_TPS"
39-
ENV_DUMP_CHECKSUM = "DTLE_DUMP_CHECKSUM"
40-
ENV_DUMP_OLDWAY = "DTLE_DUMP_OLDWAY"
41-
ENV_TESTSTUB1_DELAY = "UDUP_TESTSTUB1_DELAY"
42-
ENV_FULL_APPLY_DELAY = "DTLE_FULL_APPLY_DELAY"
43-
ENV_COUNT_INFO_SCHEMA = "DTLE_COUNT_INFO_SCHEMA"
44-
ENV_BIG_MSG_100K = "DTLE_BIG_MSG_100K"
38+
ENV_PRINT_TPS = "UDUP_PRINT_TPS"
39+
ENV_DUMP_CHECKSUM = "DTLE_DUMP_CHECKSUM"
40+
ENV_DUMP_OLDWAY = "DTLE_DUMP_OLDWAY"
41+
ENV_TESTSTUB1_DELAY = "UDUP_TESTSTUB1_DELAY"
42+
ENV_FULL_APPLY_DELAY = "DTLE_FULL_APPLY_DELAY"
43+
ENV_BIG_MSG_100K = "DTLE_BIG_MSG_100K"
4544
ENV_SKIP_GTID_EXECUTED_TABLE = "DTLE_SKIP_GTID_EXECUTED_TABLE"
46-
ENV_FORCE_MTS = "DTLE_FORCE_MTS"
45+
ENV_FORCE_MTS = "DTLE_FORCE_MTS"
46+
ENV_DTLE_LOG_TX_COMMIT = "DTLE_LOG_TX_COMMIT"
47+
4748
NatsMaxPayload = 64 * 1024 * 1024
4849

4950
LONG_LOG_LIMIT = 256

0 commit comments

Comments
 (0)