-
Notifications
You must be signed in to change notification settings - Fork 742
store: update StoreInfo inside putStoreLocked #9187
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
Conversation
Signed-off-by: okJiang <819421878@qq.com>
Signed-off-by: okJiang <819421878@qq.com>
/retest |
pkg/core/store.go
Outdated
if len(opts) > 0 { | ||
store = s.stores[store.GetID()] | ||
for _, opt := range opts { | ||
opt(store) | ||
} | ||
} else { | ||
s.stores[store.GetID()] = store | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if len(opts) > 0 { | |
store = s.stores[store.GetID()] | |
for _, opt := range opts { | |
opt(store) | |
} | |
} else { | |
s.stores[store.GetID()] = store | |
} | |
for _, opt := range opts { | |
opt(store) | |
} | |
s.stores[store.GetID()] = store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The internal store may have been modified before calling putStore, so here options are used to directly modify the internal store. If no options are provided, it indicates that the input should be a new store.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is better to split this function to Put and Modify
|
||
c.PutStore(newStore) | ||
c.hotStat.Observe(storeID, newStore.GetStoreStats()) | ||
c.PutStore(store, core.SetStoreStats(stats), core.SetLastHeartbeatTS(time.Now())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add some tests about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/retest |
It seems that we are not allowed to modify the store in StoresInfo directly; instead, we have to clone it, make modifications, and then replace it directly. I think the reason for this is that we read it in too many places, so direct write operations have been prohibited. ref https://github.com/tikv/pd/actions/runs/14354291468/job/40301155373?pr=9187 |
Signed-off-by: okJiang <819421878@qq.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9187 +/- ##
==========================================
- Coverage 75.77% 75.75% -0.02%
==========================================
Files 477 477
Lines 73438 73439 +1
==========================================
- Hits 55644 55634 -10
- Misses 14320 14329 +9
- Partials 3474 3476 +2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
} | ||
if err := c.checkStoreLabels(s); err != nil { | ||
return err | ||
} | ||
return c.setStore(s) | ||
return c.setStore(s, opts...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clone twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is here 😂
zap.Bool("physically-destroyed", physicallyDestroyed)) | ||
if err := c.setStore( | ||
store.Clone(core.SetStoreState(metapb.StoreState_Offline, physicallyDestroyed)), | ||
core.SetStoreState(metapb.StoreState_Offline, physicallyDestroyed), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err := c.setStore(newStore) | ||
err := c.setStore( | ||
store.Clone(core.SetStoreState(metapb.StoreState_Tombstone)), | ||
core.SetStoreState(metapb.StoreState_Tombstone), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lhy1024, 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 |
close tikv#9185 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
In response to a cherrypick label: new pull request created to branch |
close tikv#9185 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
close tikv#9185 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
close tikv#9185 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
close tikv#9185 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
In response to a cherrypick label: new pull request created to branch |
What problem does this PR solve?
Issue Number: Close #9185
What is changed and how does it work?
Check List
Tests
Release note