Skip to content

Commit

Permalink
table: move add TTL insert rows metrics code out of table package (#5…
Browse files Browse the repository at this point in the history
  • Loading branch information
lcwangchao committed Jul 9, 2024
1 parent 2c72c39 commit 8f0db6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 6 additions & 0 deletions pkg/executor/insert_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,12 @@ func (e *InsertValues) addRecordWithAutoIDHint(
}
}
}

if e.Table.Meta().TTLInfo != nil {
// update the TTL metrics if the table is a TTL table
vars.TxnCtx.InsertTTLRowsCount++
}

return nil
}

Expand Down
8 changes: 0 additions & 8 deletions pkg/table/tables/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,10 +1069,6 @@ func (t *TableCommon) AddRecord(sctx table.MutateContext, r []types.Datum, opts
return recordID, nil
}

if shouldIncreaseTTLMetricCount(t.meta) {
sessVars.TxnCtx.InsertTTLRowsCount += 1
}

colSizeBuffer := sctx.GetMutateBuffers().GetColSizeDeltaBufferWithCap(len(t.Cols()))
for id, col := range t.Cols() {
size, err := codec.EstimateValueSize(sc.TypeCtx(), r[id])
Expand Down Expand Up @@ -1742,10 +1738,6 @@ func shouldWriteBinlog(vars *variable.SessionVars, tblInfo *model.TableInfo) boo
return !vars.InRestrictedSQL
}

func shouldIncreaseTTLMetricCount(tblInfo *model.TableInfo) bool {
return tblInfo.TTLInfo != nil
}

func (t *TableCommon) getMutation(ctx table.MutateContext) *binlog.TableMutation {
return ctx.StmtGetMutation(t.tableID)
}
Expand Down

0 comments on commit 8f0db6f

Please sign in to comment.