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

tso, election: remove some unnecessary logs from the TSO hot path #4044

Merged
merged 4 commits into from
Aug 31, 2021

Conversation

JmPotato
Copy link
Member

@JmPotato JmPotato commented Aug 27, 2021

Signed-off-by: JmPotato ghzpotato@gmail.com

What problem does this PR solve?

Remove some unnecessary logs from the TSO hot path.

log.Warn("get timestamp too slow", zap.Duration("cost", elapsed))

This indicator can be observed through metrics, so it is not necessary to hit the log here.

log.Info("this PD is a new leader, but sync hasn't been completed yet, wait for a while")

In past experience, this log has not been very helpful and may be very noisy.

log.Error("invalid timestamp",
				zap.Any("timestamp-physical", currentPhysical),
				zap.Any("timestamp-logical", currentLogical),
				errs.ZapError(errs.ErrInvalidTimestamp))

Ditto.

What is changed and how it works?

Remove some unnecessary logs from the TSO hot path.

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 27, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • nolouch
  • rleungx

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Aug 27, 2021
@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Aug 27, 2021
@JmPotato JmPotato added component/election Election related logic. component/tso Timestamp Oracle. labels Aug 27, 2021
Signed-off-by: JmPotato <ghzpotato@gmail.com>
@@ -166,10 +164,6 @@ func (s *Server) Tso(stream pdpb.PD_TsoServer) error {
return status.Errorf(codes.Unknown, err.Error())
}

elapsed := time.Since(start)
if elapsed > slowThreshold {
log.Warn("get timestamp too slow", zap.Duration("cost", elapsed))
Copy link
Member

Choose a reason for hiding this comment

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

Why is it useless?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can get it from the metrics also.

Copy link
Member

Choose a reason for hiding this comment

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

I don't find any metrics to record it.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, you mean tsoHandleDuration.Observe(time.Since(start).Seconds())

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.

@@ -362,7 +362,6 @@ func (t *timestampOracle) getTS(leadership *election.Leadership, count uint32, s
if currentPhysical == typeutil.ZeroTime {
// If it's leader, maybe SyncTimestamp hasn't completed yet
if leadership.Check() {
log.Info("this PD is a new leader, but sync hasn't been completed yet, wait for a while")
Copy link
Contributor

Choose a reason for hiding this comment

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

also this log will be noise:

[2021/06/18 16:15:19.627 +08:00] [ERROR] [tso.go:302] ["invalid timestamp"] [timestamp={}]
[2021/06/18 16:15:19.628 +08:00] [ERROR] [tso.go:302] ["invalid timestamp"] [timestamp={}]
[2021/06/18 16:15:19.628 +08:00] [ERROR] [tso.go:302] ["invalid timestamp"] [timestamp={}]
[2021/06/18 16:15:19.685 +08:00] [ERROR] [tso.go:302] ["invalid timestamp"] [timestamp={}]
[2021/06/18 16:15:19.686 +08:00] [ERROR] [tso.go:302] ["invalid timestamp"] [timestamp={}]
[2021/06/18 16:15:19.718 +08:00] [ERROR] [tso.go:302] ["invalid timestamp"] [timestamp={}]
[2021/06/18 16:15:19.718 +08:00] [ERROR] [tso.go:302] ["invalid timestamp"] [timestamp={}]

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed. PTAL.

@codecov
Copy link

codecov bot commented Aug 27, 2021

Codecov Report

Merging #4044 (8ebb3a4) into master (5d4775b) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4044      +/-   ##
==========================================
- Coverage   74.47%   74.45%   -0.02%     
==========================================
  Files         257      257              
  Lines       25980    25972       -8     
==========================================
- Hits        19349    19338      -11     
+ Misses       4898     4896       -2     
- Partials     1733     1738       +5     
Flag Coverage Δ
unittests 74.45% <100.00%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
server/grpc_service.go 47.27% <ø> (+0.16%) ⬆️
server/tso/global_allocator.go 61.90% <ø> (+1.28%) ⬆️
server/election/leadership.go 84.61% <100.00%> (+0.70%) ⬆️
server/tso/tso.go 64.77% <100.00%> (+6.20%) ⬆️
server/election/lease.go 89.83% <0.00%> (-6.78%) ⬇️
server/tso/local_allocator.go 71.62% <0.00%> (-6.76%) ⬇️
server/schedule/region_scatterer.go 80.70% <0.00%> (-4.39%) ⬇️
server/region_syncer/client.go 77.46% <0.00%> (-4.23%) ⬇️
pkg/etcdutil/etcdutil.go 84.70% <0.00%> (-3.53%) ⬇️
client/base_client.go 82.29% <0.00%> (-2.09%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d4775b...8ebb3a4. Read the comment docs.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
Signed-off-by: JmPotato <ghzpotato@gmail.com>
@JmPotato
Copy link
Member Author

/run-unit-test

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 30, 2021
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 31, 2021
@rleungx
Copy link
Member

rleungx commented Aug 31, 2021

/merge

@ti-chi-bot
Copy link
Member

@rleungx: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

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.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 337f78d

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 31, 2021
@JmPotato
Copy link
Member Author

/run-unit-test

@ti-chi-bot ti-chi-bot merged commit c3c8c47 into tikv:master Aug 31, 2021
@JmPotato JmPotato deleted the clean_tso_log branch August 31, 2021 05:33
v01dstar pushed a commit to v01dstar/pd that referenced this pull request Oct 28, 2021
…kv#4044)

* Remove some unnecessary logs from the TSO hot path

Signed-off-by: JmPotato <ghzpotato@gmail.com>

* Remove more unnecessary logs

Signed-off-by: JmPotato <ghzpotato@gmail.com>

* Fix the test

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/election Election related logic. component/tso Timestamp Oracle. release-note-none Denotes a PR that doesn't merit a release note. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants