Skip to content

Commit

Permalink
remove all debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
CbcWestwolf committed Feb 24, 2025
1 parent 8ff59d8 commit af13a6a
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 184 deletions.
2 changes: 0 additions & 2 deletions pkg/ddl/backfilling_dist_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ type BackfillSubTaskMeta struct {
external.SortedKVMeta `json:",inline"`
}

var DecodeBackfillSubTaskMeta4Test = decodeBackfillSubTaskMeta

func decodeBackfillSubTaskMeta(raw []byte) (*BackfillSubTaskMeta, error) {
var subtask BackfillSubTaskMeta
err := json.Unmarshal(raw, &subtask)
Expand Down
18 changes: 0 additions & 18 deletions pkg/ddl/backfilling_dist_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
brlogutil "github.com/pingcap/tidb/br/pkg/logutil"
"github.com/pingcap/tidb/br/pkg/storage"
"github.com/pingcap/tidb/pkg/ddl/ingest"
"github.com/pingcap/tidb/pkg/ddl/logutil"
Expand Down Expand Up @@ -386,17 +385,7 @@ func generateGlobalSortIngestPlan(
if kvMetaGroups[i] == nil {
kvMetaGroups[i] = &external.SortedKVMeta{}
}
logger.Warn("[date0218] generateGlobalSortIngestPlan before merged", zap.Int("i", i),
brlogutil.Key("startKey", kvMetaGroups[i].StartKey),
brlogutil.Key("endKey", kvMetaGroups[i].EndKey),
brlogutil.Key("cur.startKey", cur.StartKey),
brlogutil.Key("cur.endKey", cur.EndKey),
)
kvMetaGroups[i].Merge(cur)
// [date0218] All of these endKey can NOT be decoded
logger.Warn("[date0218] generateGlobalSortIngestPlan after merged",
brlogutil.Key("startKey", kvMetaGroups[i].StartKey),
brlogutil.Key("endKey", kvMetaGroups[i].EndKey))
}
})
if err != nil {
Expand Down Expand Up @@ -480,18 +469,15 @@ func splitSubtaskMetaForOneKVMetaGroup(

startKey := kvMeta.StartKey
var endKey kv.Key
logger.Warn("[date0218] splitSubtaskMetaForOneKVMetaGroup", brlogutil.Key("startKey", kvMeta.StartKey), brlogutil.Key("endKey", kvMeta.EndKey))
for {
endKeyOfGroup, dataFiles, statFiles, interiorRangeJobKeys, interiorRegionSplitKeys, err := splitter.SplitOneRangesGroup()
if err != nil {
return nil, err
}
if len(endKeyOfGroup) == 0 {
endKey = kvMeta.EndKey
logger.Warn("[date0218] splitSubtaskMetaForOneKVMetaGroup get endKey with kvMeta.EndKey")
} else {
endKey = kv.Key(endKeyOfGroup).Clone()
logger.Warn("[date0218] splitSubtaskMetaForOneKVMetaGroup get endKey without kvMeta.EndKey", brlogutil.Key("endKey", endKey))
}
logger.Info("split subtask range",
zap.String("startKey", hex.EncodeToString(startKey)),
Expand All @@ -509,9 +495,6 @@ func splitSubtaskMetaForOneKVMetaGroup(
regionSplitKeys = append(regionSplitKeys, startKey)
regionSplitKeys = append(regionSplitKeys, interiorRegionSplitKeys...)
regionSplitKeys = append(regionSplitKeys, endKey)
for i, k := range regionSplitKeys {
logger.Warn("[date0218] splitSubtaskMetaForOneKVMetaGroup regionSplitKeys", zap.Int("i", i), brlogutil.Key("key", k))
}
m := &BackfillSubTaskMeta{
MetaGroups: []*external.SortedKVMeta{{
StartKey: startKey,
Expand Down Expand Up @@ -682,7 +665,6 @@ func forEachBackfillSubtaskMeta(
}
for _, subTaskMeta := range subTaskMetas {
subtask, err := decodeBackfillSubTaskMeta(subTaskMeta)
// TODO: 0218 add log here for subtask
if err != nil {
logutil.DDLLogger().Error("unmarshal error", zap.Error(err))
return errors.Trace(err)
Expand Down
11 changes: 0 additions & 11 deletions pkg/ddl/backfilling_dist_scheduler_test.go

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pkg/ddl/backfilling_import_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func (m *cloudImportExecutor) RunSubtask(ctx context.Context, subtask *proto.Sub
if jobKeys == nil {
jobKeys = sm.RangeSplitKeys
}
// TODO[0224]: print all.StartKey, all.EndKey and sm.RangeSplitKeys here
err = local.CloseEngine(ctx, &backend.EngineConfig{
External: &backend.ExternalEngineConfig{
StorageURI: m.cloudStoreURI,
Expand Down
4 changes: 0 additions & 4 deletions pkg/ddl/backfilling_read_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
brlogutil "github.com/pingcap/tidb/br/pkg/logutil"
"github.com/pingcap/tidb/pkg/config"
"github.com/pingcap/tidb/pkg/ddl/ingest"
"github.com/pingcap/tidb/pkg/ddl/logutil"
Expand Down Expand Up @@ -301,10 +300,7 @@ func (r *readIndexExecutor) buildExternalStorePipeline(
kvMeta = &external.SortedKVMeta{}
s.metaGroups[summary.GroupOffset] = kvMeta
}
logutil.DDLLogger().Warn("[date0224] onClose before merge", brlogutil.Key("startKey", kvMeta.StartKey), brlogutil.Key("endKey", kvMeta.EndKey),
brlogutil.Key("summary.Min", summary.Min), brlogutil.Key("summary.Max", summary.Max))
kvMeta.MergeSummary(summary)
logutil.DDLLogger().Warn("[date0224] onClose after merge", brlogutil.Key("startKey", kvMeta.StartKey), brlogutil.Key("endKey", kvMeta.EndKey))
s.mu.Unlock()
}
var idxNames strings.Builder
Expand Down
4 changes: 0 additions & 4 deletions pkg/disttask/framework/storage/subtask_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ package storage
import (
"context"

brlogutil "github.com/pingcap/tidb/br/pkg/logutil"
"github.com/pingcap/tidb/pkg/disttask/framework/proto"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/sqlexec"
"go.uber.org/zap"
)

// StartSubtask updates the subtask state to running.
Expand Down Expand Up @@ -50,7 +47,6 @@ func (mgr *TaskManager) StartSubtask(ctx context.Context, subtaskID int64, execI

// FinishSubtask updates the subtask meta and mark state to succeed.
func (mgr *TaskManager) FinishSubtask(ctx context.Context, execID string, id int64, meta []byte) error {
logutil.BgLogger().Warn("[date0218] FinishSubtask", zap.Int64("id", id), brlogutil.Key("meta", meta))
_, err := mgr.ExecuteSQLWithNewSession(ctx, `update mysql.tidb_background_subtask
set meta = %?, state = %?, state_update_time = unix_timestamp(), end_time = CURRENT_TIMESTAMP()
where id = %? and exec_id = %?`,
Expand Down
7 changes: 1 addition & 6 deletions pkg/disttask/framework/storage/task_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ import (
"github.com/docker/go-units"
"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
brlogutil "github.com/pingcap/tidb/br/pkg/logutil"
"github.com/pingcap/tidb/pkg/disttask/framework/proto"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/sessionctx/vardef"
"github.com/pingcap/tidb/pkg/util"
"github.com/pingcap/tidb/pkg/util/chunk"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/sqlexec"
clitutil "github.com/tikv/client-go/v2/util"
"go.uber.org/zap"
)

const (
Expand Down Expand Up @@ -718,9 +715,7 @@ func (*TaskManager) insertSubtasks(ctx context.Context, se sessionctx.Context, s
args = make([]any, 0, len(subtasks)*7)
)
sb.WriteString(`insert into mysql.tidb_background_subtask(` + InsertSubtaskColumns + `) values `)
for i, subtask := range subtasks {
logutil.BgLogger().Warn("[date0218] insertSubtasks", zap.Int("i", i), zap.Int64("id", subtask.TaskID), zap.Int64("step", int64(subtask.Step)),
brlogutil.Key("meta", subtask.Meta))
for _, subtask := range subtasks {
markerList = append(markerList, "(%?, %?, %?, %?, %?, %?, %?, %?, CURRENT_TIMESTAMP(), '{}', '{}')")
args = append(args, subtask.Step, subtask.TaskID, subtask.ExecID, subtask.Meta,
proto.SubtaskStatePending, proto.Type2Int(subtask.Type), subtask.Concurrency, subtask.Ordinal)
Expand Down
3 changes: 0 additions & 3 deletions pkg/lightning/backend/external/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"slices"

brlogutil "github.com/pingcap/tidb/br/pkg/logutil"
"github.com/pingcap/tidb/br/pkg/storage"
"github.com/pingcap/tidb/pkg/util/logutil"
"go.uber.org/zap"
Expand Down Expand Up @@ -229,8 +228,6 @@ func (r *RangeSplitter) SplitOneRangesGroup() (
}
if r.recordRegionSplitAfterNextProp {
r.regionSplitKeys = append(r.regionSplitKeys, slices.Clone(prop.firstKey))
lastKey := r.regionSplitKeys[len(r.regionSplitKeys)-1]
r.logger.Warn("[date0218] SplitOneRangesGroup", zap.Int("len(key)", len(lastKey)), brlogutil.Key("key", lastKey))
r.recordRegionSplitAfterNextProp = false
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/lightning/backend/external/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/docker/go-units"
"github.com/pingcap/errors"
brlogutil "github.com/pingcap/tidb/br/pkg/logutil"
"github.com/pingcap/tidb/br/pkg/storage"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/lightning/log"
Expand Down Expand Up @@ -267,7 +266,6 @@ func NewSortedKVMeta(summary *WriterSummary) *SortedKVMeta {
if summary == nil || (len(summary.Min) == 0 && len(summary.Max) == 0) {
return &SortedKVMeta{}
}
logutil.BgLogger().Warn("[date0224] NewSortedKVMeta", brlogutil.Key("summary.Min", []byte(summary.Min)), brlogutil.Key("summary.Max", []byte(summary.Max)))
return &SortedKVMeta{
StartKey: summary.Min.Clone(),
EndKey: summary.Max.Clone().Next(),
Expand Down
4 changes: 1 addition & 3 deletions pkg/lightning/backend/external/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/pingcap/tidb/pkg/lightning/backend/encode"
"github.com/pingcap/tidb/pkg/lightning/backend/kv"
"github.com/pingcap/tidb/pkg/lightning/common"
"github.com/pingcap/tidb/pkg/lightning/log"
"github.com/pingcap/tidb/pkg/lightning/membuf"
"github.com/pingcap/tidb/pkg/metrics"
"github.com/pingcap/tidb/pkg/util/logutil"
Expand Down Expand Up @@ -190,7 +189,7 @@ func (b *WriterBuilder) Build(
filenamePrefix := filepath.Join(prefix, writerID)
keyAdapter := common.KeyAdapter(common.NoopKeyAdapter{})
if b.keyDupeEncoding {
keyAdapter = common.DupDetectKeyAdapter{Logger: log.Logger{logutil.BgLogger()}}
keyAdapter = common.DupDetectKeyAdapter{}
}
p := membuf.NewPool(
membuf.WithBlockNum(0),
Expand Down Expand Up @@ -416,7 +415,6 @@ func (w *Writer) Close(ctx context.Context) error {
zap.Int("kv-cnt-cap", cap(w.kvLocations)),
zap.String("minKey", hex.EncodeToString(w.minKey)),
zap.String("maxKey", hex.EncodeToString(w.maxKey)))
// TODO[0224]: note that the minKey and maxKey here can be decoded

w.kvLocations = nil
w.onClose(&WriterSummary{
Expand Down
2 changes: 1 addition & 1 deletion pkg/lightning/backend/local/engine_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func newEngineManager(config BackendConfig, storeHelper StoreHelper, logger log.
if err != nil {
return nil, common.ErrOpenDuplicateDB.Wrap(err).GenWithStackByArgs()
}
keyAdapter = common.DupDetectKeyAdapter{Logger: logger}
keyAdapter = common.DupDetectKeyAdapter{}
}
alloc := manual.Allocator{}
if RunInTest {
Expand Down
15 changes: 3 additions & 12 deletions pkg/lightning/common/key_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ package common

import (
"github.com/pingcap/errors"
"github.com/pingcap/tidb/br/pkg/logutil"
"github.com/pingcap/tidb/pkg/lightning/log"
"github.com/pingcap/tidb/pkg/util/codec"
"go.uber.org/zap"
)

// KeyAdapter is used to encode and decode keys so that duplicate key can be
Expand Down Expand Up @@ -71,12 +68,10 @@ var _ KeyAdapter = NoopKeyAdapter{}

// DupDetectKeyAdapter is a key adapter that appends rowID to the key to avoid
// overwritten.
type DupDetectKeyAdapter struct {
Logger log.Logger
}
type DupDetectKeyAdapter struct{}

// Encode implements KeyAdapter.
func (d DupDetectKeyAdapter) Encode(dst []byte, key []byte, rowID []byte) []byte {
func (DupDetectKeyAdapter) Encode(dst []byte, key []byte, rowID []byte) []byte {
dst = codec.EncodeBytes(dst, key)
dst = reallocBytes(dst, len(rowID)+2)
dst = append(dst, rowID...)
Expand All @@ -86,21 +81,17 @@ func (d DupDetectKeyAdapter) Encode(dst []byte, key []byte, rowID []byte) []byte
}

// Decode implements KeyAdapter.
func (d DupDetectKeyAdapter) Decode(dst []byte, data []byte) ([]byte, error) {
func (DupDetectKeyAdapter) Decode(dst []byte, data []byte) ([]byte, error) {
if len(data) < 2 {
d.Logger.Warn("[date0218] Decode error 1", logutil.Key("data", data))
return nil, errors.New("insufficient bytes to decode value")
}
rowIDLen := uint16(data[len(data)-2])<<8 | uint16(data[len(data)-1])
tailLen := int(rowIDLen + 2)
if len(data) < tailLen {
d.Logger.Warn("[date0218] Decode error 2", logutil.Key("data", data), zap.Uint16("rowIDLen", rowIDLen), zap.Int("tailLen", tailLen), zap.Stack("stack"))
return nil, errors.New("insufficient bytes to decode value")
}
_, key, err := codec.DecodeBytes(data[:len(data)-tailLen], dst[len(dst):cap(dst)])
if err != nil {
d.Logger.Warn("[date0218] Decode error 3", logutil.Key("data", data), zap.Uint16("rowIDLen", rowIDLen), zap.Int("tailLen", tailLen),
logutil.Key("key", key), zap.Error(err))
return nil, err
}
if len(dst) == 0 {
Expand Down
Loading

0 comments on commit af13a6a

Please sign in to comment.