-
Notifications
You must be signed in to change notification settings - Fork 725
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
server/cache: add kv to cluster #382
Conversation
It's more safe to update cache and kv consistenly inside cluster.
8d9b537
to
8e41da6
Compare
return c.innerPutMeta(proto.Clone(meta).(*metapb.Cluster)) | ||
} | ||
|
||
func (c *clusterInfo) innerPutMeta(meta *metapb.Cluster) error { |
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.
I prefer putMetaLocked
which means that we must lock before calling this function.
@@ -243,8 +244,9 @@ func newClusterInfo(id IDAllocator) *clusterInfo { | |||
} | |||
|
|||
// Return nil if cluster is not bootstrapped. | |||
func loadClusterInfo(id IDAllocator, kv *kv) (*clusterInfo, error) { | |||
func newClusterInfoWithKV(id IDAllocator, kv *kv) (*clusterInfo, error) { |
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.
newClusterInfo is ok. you use two args, so WithKV is not proper here.
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.
We already have a newClusterInfo
without kv for test.
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.
so we should use a better name here.
Rest LGTM |
PTAL @overvenus |
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.
LGTM
We update cache and kv separately in different places, which may not be safe and hard to maintain.
This PR updates both cache and kv consistently inside
clusterInfo
.