Skip to content

Commit 400020c

Browse files
authored
adjust debug log (#19696)
- lower log print threshold - check rowid of insert batch Approved by: @LeftHandCold, @XuPeng-SH, @sukki37
1 parent dbab6bb commit 400020c

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

pkg/objectio/injects.go

+6
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,19 @@ const (
3030
FJ_TracePartitionState = "fj/trace/partitionstate"
3131

3232
FJ_Debug19524 = "fj/debug/19524"
33+
FJ_Debug19357 = "fj/debug/19357"
3334
)
3435

3536
func Debug19524Injected() bool {
3637
_, _, injected := fault.TriggerFault(FJ_Debug19524)
3738
return injected
3839
}
3940

41+
func Debug19357Injected() (bool, int64) {
42+
iret, _, injected := fault.TriggerFault(FJ_Debug19357)
43+
return injected, iret
44+
}
45+
4046
func RangesInjected(name string) bool {
4147
_, sarg, injected := fault.TriggerFault(FJ_TraceRanges)
4248
if !injected {

pkg/vm/engine/disttae/local_disttae_datasource.go

+21-19
Original file line numberDiff line numberDiff line change
@@ -406,39 +406,34 @@ func checkWorkspaceEntryType(
406406
return (entry.typ == DELETE) && (entry.fileName == "")
407407
}
408408

409-
func checkTxnOffsetZero(ls *LocalDisttaeDataSource, writes []Entry) {
410-
if len(writes) > 200 && ls.txnOffset == 0 && ls.table.accountId == 0 && ls.table.tableName == "mo_increment_columns" {
411-
logutil.Info("yyyyyy zero txnOffset",
412-
zap.String("txn", hex.EncodeToString(ls.table.db.op.Txn().ID)),
413-
zap.Bool("isSnapOp", ls.table.db.op.IsSnapOp()),
414-
zap.String("entries", stringifySlice(writes[len(writes)-2:], func(a any) string {
415-
e := a.(Entry)
416-
batstr := "nil"
417-
if e.bat != nil {
418-
batstr = common.MoBatchToString(e.bat, 3)
419-
}
420-
return e.String() + " " + batstr
421-
})))
422-
}
423-
}
424-
425409
func checkTxnLastInsertRow(ls *LocalDisttaeDataSource, writes []Entry, cursor int, outBatch *batch.Batch) {
426-
if len(writes) > 400 && ls.table.accountId == 0 && ls.table.tableName == "mo_increment_columns" && writes[len(writes)-1].typ == INSERT && writes[len(writes)-1].tableId == ls.table.tableId {
410+
injected, writesT := objectio.Debug19357Injected()
411+
if injected && int64(len(writes)) > writesT && len(outBatch.Vecs) == 3 && ls.table.accountId == 0 && ls.table.tableName == "mo_increment_columns" && writes[len(writes)-1].typ == INSERT && writes[len(writes)-1].tableId == ls.table.tableId {
412+
outLen := outBatch.Vecs[0].Length()
413+
var slim *batch.Batch
414+
if outLen > 0 {
415+
start := outLen - 3
416+
if start < 0 {
417+
start = 0
418+
}
419+
slim, _ = outBatch.Window(start, outLen)
420+
}
421+
427422
logutil.Info("yyyyyy checkTxnLastInsertRow",
428423
zap.String("txn", hex.EncodeToString(ls.table.db.op.Txn().ID)),
429424
zap.Int("txnOffset", ls.txnOffset),
430425
zap.Int("cursor", cursor),
431426
zap.Int("writes", len(writes)),
432427
zap.Bool("isSnapOp", ls.table.db.op.IsSnapOp()),
433-
zap.String("entries", stringifySlice(writes[len(writes)-2:], func(a any) string {
428+
zap.String("entries", stringifySlice(writes[len(writes)-1:], func(a any) string {
434429
e := a.(Entry)
435430
batstr := "nil"
436431
if e.bat != nil {
437432
batstr = common.MoBatchToString(e.bat, 3)
438433
}
439434
return e.String() + " " + batstr
440435
})),
441-
zap.String("outBatch", common.MoBatchToString(outBatch, 3)),
436+
zap.String("outBatch", common.MoBatchToString(slim, 3)),
442437
)
443438
}
444439
}
@@ -488,13 +483,20 @@ func (ls *LocalDisttaeDataSource) filterInMemUnCommittedInserts(
488483
retainedRowIds = vector.MustFixedColWithTypeCheck[objectio.Rowid](entry.bat.Vecs[0])
489484
offsets := engine_util.RowIdsToOffset(retainedRowIds, int64(0)).([]int64)
490485

486+
offsetLen := len(offsets)
487+
badOffsetStart := offsetLen > 0 && offsets[0] > 0
488+
491489
b := retainedRowIds[0].BorrowBlockID()
492490
sels, err := ls.ApplyTombstones(
493491
ls.ctx, b, offsets, engine.Policy_CheckUnCommittedOnly)
494492
if err != nil {
495493
return err
496494
}
497495

496+
if (len(sels) < offsetLen || badOffsetStart) && ls.table.accountId == 0 && ls.table.tableName == "mo_increment_columns" {
497+
logutil.Info("Shrink retainedRowIds", zap.Any("sels", sels), zap.Any("offsetsLen", offsetLen), zap.Bool("badOffsetStart", badOffsetStart), zap.Int("wsCursor", ls.wsCursor), zap.Int("txnOffset", ls.txnOffset))
498+
}
499+
498500
if len(sels) == 0 {
499501
continue
500502
}

pkg/vm/engine/disttae/local_disttae_datasource_test.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/stretchr/testify/require"
2323

24+
"github.com/matrixorigin/matrixone/pkg/common/mpool"
2425
"github.com/matrixorigin/matrixone/pkg/container/batch"
2526
"github.com/matrixorigin/matrixone/pkg/container/types"
2627
"github.com/matrixorigin/matrixone/pkg/container/vector"
@@ -30,6 +31,7 @@ import (
3031
"github.com/matrixorigin/matrixone/pkg/sql/colexec"
3132
"github.com/matrixorigin/matrixone/pkg/testutil"
3233
"github.com/matrixorigin/matrixone/pkg/txn/client"
34+
"github.com/matrixorigin/matrixone/pkg/util/fault"
3335
"github.com/matrixorigin/matrixone/pkg/vm/engine/disttae/logtailreplay"
3436
"github.com/matrixorigin/matrixone/pkg/vm/engine/engine_util"
3537
)
@@ -161,8 +163,18 @@ func TestXxx1(t *testing.T) {
161163
},
162164
},
163165
}
166+
fault.Enable()
167+
defer fault.Disable()
168+
fault.AddFaultPoint(context.Background(), objectio.FJ_Debug19357, ":::", "echo", 20, "")
169+
t.Log(objectio.Debug19357Injected())
164170
writes := make([]Entry, 200)
165171
writes = append(writes, Entry{typ: INSERT}, Entry{typ: INSERT, bat: batch.EmptyBatch})
166-
checkTxnLastInsertRow(ls, writes, 42, batch.EmptyBatch)
167-
checkTxnOffsetZero(ls, writes)
172+
outBatch := batch.NewWithSize(3)
173+
m := mpool.MustNewZero()
174+
for i := 0; i < 3; i++ {
175+
outBatch.Vecs[i] = vector.NewVec(types.T_int32.ToType())
176+
vector.AppendFixed[int32](outBatch.Vecs[i], int32(i), false, m)
177+
}
178+
checkTxnLastInsertRow(ls, writes, 42, outBatch)
179+
168180
}

pkg/vm/engine/tae/logtail/snapshot.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ func (sm *SnapshotMeta) updateTableInfo(
495495
continue
496496
}
497497
if _, ok := sm.aobjDelTsMap[commitTs]; ok {
498-
logutil.Infof("yyyy skip table %v @ %v", pk.ErrString(nil), commitTs.ToString())
498+
logutil.Infof("snapshotMeta skip table %v @ %v", pk.ErrString(nil), commitTs.ToString())
499499
continue
500500
}
501501
deleteRows = append(deleteRows, tombstone{

0 commit comments

Comments
 (0)