Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: use package-level logger which preset "category" field #52885

Merged
merged 5 commits into from
Apr 26, 2024

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Apr 25, 2024

What problem does this PR solve?

Issue Number: close #52883

Problem Summary:

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.
$ tiup playground nightly --tiflash 0 --without-monitor --db.binpath ~/Projects/tidb/bin/tidb-server

check log

image
image

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: lance6716 <lance6716@gmail.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-tests-checked release-note-none size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 25, 2024
Copy link

tiprow bot commented Apr 25, 2024

Hi @lance6716. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@lance6716
Copy link
Contributor Author

/ok-to-test

Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
@lance6716
Copy link
Contributor Author

/retest

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

Attention: Patch coverage is 53.36927% with 173 lines in your changes are missing coverage. Please review.

Project coverage is 55.2474%. Comparing base (e8c397f) to head (00cd2df).
Report is 7 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #52885         +/-   ##
=================================================
- Coverage   72.4341%   55.2474%   -17.1867%     
=================================================
  Files          1481       1593        +112     
  Lines        428353     598449     +170096     
=================================================
+ Hits         310274     330628      +20354     
- Misses        98884     244842     +145958     
- Partials      19195      22979       +3784     
Flag Coverage Δ
integration 22.1066% <30.4582%> (?)
unit 71.2035% <49.8652%> (-0.1149%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 49.7859% <ø> (+8.5684%) ⬆️

Copy link
Contributor

@D3Hunter D3Hunter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest lgtm

"github.com/pingcap/tidb/pkg/util/memory"
"github.com/pingcap/tidb/pkg/util/size"
"go.uber.org/zap"
)

var (
litLogger = logutil.BgLogger().With(zap.String(logutil.LogFieldCategory, "ddl-ingest"))
// LitLogger is the package-level logger.
LitLogger = zap.NewNop()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave previous value? so we can see logs in test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, not using a uniform initialization log interface may miss some configurations.

Copy link
Contributor Author

@lance6716 lance6716 Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave previous value? so we can see logs in test

In fact I think printing all message of passed unit test is useless, makes me hard to locate the log of failed tests. I'll try to initialize these logger to https://pkg.go.dev/go.uber.org/zap/zaptest#NewLogger

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave previous value? so we can see logs in test

In fact I think printing all message of passed unit test is useless, makes me hard to locate the log of failed tests. I'll try to initialize these logger to https://pkg.go.dev/go.uber.org/zap/zaptest#NewLogger

I'll revert to previous values, it's hard to write a helper function and use it once to get testing.T for zaptest.NewLogger

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found https://github.com/pingcap/tidb/blob/master/pkg/statistics/handle/logutil/logutil.go

Do you think this style is good? The SamplerLogger can also replace our manually down-sample logging logic

tidb/pkg/ddl/backfilling.go

Lines 279 to 280 in e8c397f

lastLogCount := 0
lastLogTime := time.Now()

cc @D3Hunter @zimulala

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave previous value? so we can see logs in test

In fact I think printing all message of passed unit test is useless, makes me hard to locate the log of failed tests. I'll try to initialize these logger to https://pkg.go.dev/go.uber.org/zap/zaptest#NewLogger

if the test is flaky, it might help, especially for cases that only trigger on some timeline, such as DXF

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zaptest.NewLogger will print the content when test failed, or use go test -v.

pkg/ddl/syncer/syncer.go Outdated Show resolved Hide resolved
pkg/ddl/ingest/env.go Outdated Show resolved Hide resolved
Signed-off-by: lance6716 <lance6716@gmail.com>
Signed-off-by: lance6716 <lance6716@gmail.com>
Copy link
Collaborator

@Benjamin2037 Benjamin2037 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

ti-chi-bot bot commented Apr 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, D3Hunter

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

ti-chi-bot bot commented Apr 26, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-04-25 11:07:09.45381419 +0000 UTC m=+258386.193717114: ☑️ agreed by D3Hunter.
  • 2024-04-26 06:07:48.354146692 +0000 UTC m=+326825.094049611: ☑️ agreed by Benjamin2037.

@ti-chi-bot ti-chi-bot bot merged commit 10971ea into pingcap:master Apr 26, 2024
23 checks passed
@lance6716
Copy link
Contributor Author

/cherry-pick release-8.1

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 28, 2024
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

@lance6716: new pull request created to branch release-8.1: #52942.

In response to this:

/cherry-pick release-8.1

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test release-note-none size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong package level logger initialization timing
5 participants