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: fix an invalid err != nil check #8523

Merged
merged 2 commits into from
Aug 14, 2024
Merged

Conversation

JmPotato
Copy link
Member

@JmPotato JmPotato commented Aug 14, 2024

What problem does this PR solve?

Issue Number: close #8524.

var mergedTS time.Time
for _, id := range mergeList {
ts, err := kgm.tsoSvcStorage.LoadTimestamp(endpoint.KeyspaceGroupGlobalTSPath(id))
if err != nil {
log.Error("failed to load the keyspace group TSO",
zap.String("member", kgm.tsoServiceID.ServiceAddr),
zap.Uint32("merge-target-id", mergeTargetID),
zap.Any("merge-list", mergeList),
zap.Uint32("merge-id", id),
zap.Time("ts", ts),
zap.Error(err))
break
}
if ts.After(mergedTS) {
mergedTS = ts
}
}
if err != nil {
continue
}

Since the err in the loop is a local variable, so the check at line 1382 will always be false before this fix.

What is changed and how does it work?

Use the continue label to retry the whole merge loop correctly.

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

@JmPotato JmPotato added component/tso Timestamp Oracle. component/keyspace Key space. labels Aug 14, 2024
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 14, 2024
@JmPotato JmPotato changed the title tso: fix an invalid err == nil check tso: fix an invalid err != nil check Aug 14, 2024
Copy link
Contributor

@lhy1024 lhy1024 left a comment

Choose a reason for hiding this comment

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

We also need to pick it to other branches and pd-cse.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 14, 2024
Copy link
Member

@okJiang okJiang left a comment

Choose a reason for hiding this comment

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

It is better to use continue xxxxLable in Line 1376 instead of break

Copy link

codecov bot commented Aug 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.45%. Comparing base (1c1cd99) to head (5b02529).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8523      +/-   ##
==========================================
+ Coverage   77.40%   77.45%   +0.04%     
==========================================
  Files         473      473              
  Lines       61934    61934              
==========================================
+ Hits        47941    47968      +27     
+ Misses      10409    10379      -30     
- Partials     3584     3587       +3     
Flag Coverage Δ
unittests 77.45% <100.00%> (+0.04%) ⬆️

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

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 14, 2024
Copy link
Contributor

ti-chi-bot bot commented Aug 14, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-14 03:47:05.750903953 +0000 UTC m=+326110.454373594: ☑️ agreed by lhy1024.
  • 2024-08-14 03:55:38.032198005 +0000 UTC m=+326622.735667645: ☑️ agreed by rleungx.

Copy link
Contributor

ti-chi-bot bot commented Aug 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lhy1024, okJiang, rleungx

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

Signed-off-by: JmPotato <ghzpotato@gmail.com>
Signed-off-by: JmPotato <ghzpotato@gmail.com>
@ti-chi-bot ti-chi-bot bot merged commit 3117f99 into tikv:master Aug 14, 2024
21 checks passed
@JmPotato JmPotato deleted the fix_err_nil branch August 14, 2024 04:51
@JmPotato JmPotato added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Aug 14, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #8525.

@JmPotato JmPotato added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Aug 14, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #8526.

@JmPotato
Copy link
Member Author

/cherry-pick release-8.3

@ti-chi-bot
Copy link
Member

@JmPotato: new pull request created to branch release-8.3: #8527.

In response to this:

/cherry-pick release-8.3

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 bot pushed a commit that referenced this pull request Aug 14, 2024
close #8524

Use the continue label to retry the whole merge loop correctly.

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

Co-authored-by: JmPotato <ghzpotato@gmail.com>
JmPotato added a commit to JmPotato/pd that referenced this pull request Aug 14, 2024
close tikv#8524

Use the continue label to retry the whole merge loop correctly.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
ti-chi-bot bot pushed a commit that referenced this pull request Aug 14, 2024
close #8524

Use the continue label to retry the whole merge loop correctly.

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

Co-authored-by: JmPotato <ghzpotato@gmail.com>
ti-chi-bot bot added a commit that referenced this pull request Sep 14, 2024
close #8524

Use the continue label to retry the whole merge loop correctly.

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

Co-authored-by: JmPotato <ghzpotato@gmail.com>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
Co-authored-by: Ryan Leung <rleungx@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved component/keyspace Key space. component/tso Timestamp Oracle. dco-signoff: yes Indicates the PR's author has signed the dco. lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An invalid err != nil check may cause the merged TS inconsistent
5 participants