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

[DNM] rename resolved-ts to watermark #8012

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const (
PProfBlock = "/pd/api/v1/debug/pprof/block"
PProfGoroutine = "/pd/api/v1/debug/pprof/goroutine"
// Others
MinResolvedTSPrefix = "/pd/api/v1/min-resolved-ts"
MinWatermarkPrefix = "/pd/api/v1/min-resolved-ts"
Cluster = "/pd/api/v1/cluster"
ClusterStatus = "/pd/api/v1/cluster/status"
Status = "/pd/api/v1/status"
Expand Down
27 changes: 17 additions & 10 deletions client/http/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ type Client interface {
SetSnapshotRecoveringMark(context.Context) error
DeleteSnapshotRecoveringMark(context.Context) error
/* Other interfaces */
// GetMinResolvedTSByStoresIDs will be replaced by GetMinWatermarkByStoresIDs.
GetMinResolvedTSByStoresIDs(context.Context, []uint64) (uint64, map[uint64]uint64, error)
GetMinWatermarkByStoresIDs(context.Context, []uint64) (uint64, map[uint64]uint64, error)
GetPDVersion(context.Context) (string, error)
/* Micro Service interfaces */
GetMicroServiceMembers(context.Context, string) ([]MicroServiceMember, error)
Expand Down Expand Up @@ -838,15 +840,20 @@ func (c *client) SetSchedulerDelay(ctx context.Context, scheduler string, delayS
WithBody(inputJSON))
}

// GetMinResolvedTSByStoresIDs get min-resolved-ts by stores IDs.
// Compatible with the old API.
func (c *client) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs []uint64) (uint64, map[uint64]uint64, error) {
return c.GetMinWatermarkByStoresIDs(ctx, storeIDs)
}

// GetMinWatermarkByStoresIDs get min-resolved-ts by stores IDs.
// - When storeIDs has zero length, it will return (cluster-level's min_resolved_ts, nil, nil) when no error.
// - When storeIDs is {"cluster"}, it will return (cluster-level's min_resolved_ts, stores_min_resolved_ts, nil) when no error.
// - When storeID is specified to ID lists, it will return (min_resolved_ts of given stores, stores_min_resolved_ts, nil) when no error.
func (c *client) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs []uint64) (uint64, map[uint64]uint64, error) {
uri := MinResolvedTSPrefix
func (c *client) GetMinWatermarkByStoresIDs(ctx context.Context, storeIDs []uint64) (uint64, map[uint64]uint64, error) {
uri := MinWatermarkPrefix
// scope is an optional parameter, it can be `cluster` or specified store IDs.
// - When no scope is given, cluster-level's min_resolved_ts will be returned and storesMinResolvedTS will be nil.
// - When scope is `cluster`, cluster-level's min_resolved_ts will be returned and storesMinResolvedTS will be filled.
// - When no scope is given, cluster-level's min_resolved_ts will be returned and storesMinWatermark will be nil.
// - When scope is `cluster`, cluster-level's min_resolved_ts will be returned and storesMinWatermark will be filled.
// - When scope given a list of stores, min_resolved_ts will be provided for each store
// and the scope-specific min_resolved_ts will be returned.
if len(storeIDs) != 0 {
Expand All @@ -857,22 +864,22 @@ func (c *client) GetMinResolvedTSByStoresIDs(ctx context.Context, storeIDs []uin
uri = fmt.Sprintf("%s?scope=%s", uri, strings.Join(storeIDStrs, ","))
}
resp := struct {
MinResolvedTS uint64 `json:"min_resolved_ts"`
MinWatermark uint64 `json:"min_resolved_ts"`
IsRealTime bool `json:"is_real_time,omitempty"`
StoresMinResolvedTS map[uint64]uint64 `json:"stores_min_resolved_ts"`
StoresMinWatermark map[uint64]uint64 `json:"stores_min_resolved_ts"`
}{}
err := c.request(ctx, newRequestInfo().
WithName(getMinResolvedTSByStoresIDsName).
WithName(getMinWatermarkByStoresIDsName).
WithURI(uri).
WithMethod(http.MethodGet).
WithResp(&resp))
if err != nil {
return 0, nil, err
}
if !resp.IsRealTime {
return 0, nil, errors.Trace(errors.New("min resolved ts is not enabled"))
return 0, nil, errors.Trace(errors.New("min watermark is not enabled"))
}
return resp.MinResolvedTS, resp.StoresMinResolvedTS, nil
return resp.MinWatermark, resp.StoresMinWatermark, nil
}

// GetMicroServiceMembers gets the members of the microservice.
Expand Down
2 changes: 1 addition & 1 deletion client/http/request_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const (
patchRegionLabelRulesName = "PatchRegionLabelRules"
accelerateScheduleName = "AccelerateSchedule"
accelerateScheduleInBatchName = "AccelerateScheduleInBatch"
getMinResolvedTSByStoresIDsName = "GetMinResolvedTSByStoresIDs"
getMinWatermarkByStoresIDsName = "GetMinResolvedTSByStoresIDs"
getMicroServiceMembersName = "GetMicroServiceMembers"
getMicroServicePrimaryName = "GetMicroServicePrimary"
getPDVersionName = "GetPDVersion"
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ go 1.21
require (
github.com/AlekSi/gocov-xml v1.0.0
github.com/BurntSushi/toml v0.3.1
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/aws/aws-sdk-go-v2/config v1.18.19
github.com/aws/aws-sdk-go-v2/credentials v1.13.18
github.com/aws/aws-sdk-go-v2/service/kms v1.20.8
Expand Down Expand Up @@ -207,3 +208,5 @@ require (
moul.io/zapgorm2 v1.1.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

replace github.com/pingcap/kvproto => github.com/zhangjinpeng87/kvproto v0.0.0-20240329201502-02a86434e2e5
Loading
Loading