@@ -16,6 +16,7 @@ package api
1616
1717import (
1818 "net/http"
19+ "time"
1920
2021 "github.com/gorilla/mux"
2122 "github.com/tikv/pd/pkg/storage/endpoint"
@@ -38,8 +39,9 @@ func newServiceGCSafepointHandler(svr *server.Server, rd *render.Render) *servic
3839// ListServiceGCSafepoint is the response for list service GC safepoint.
3940// NOTE: This type is exported by HTTP API. Please pay more attention when modifying it.
4041type ListServiceGCSafepoint struct {
41- ServiceGCSafepoints []* endpoint.ServiceSafePoint `json:"service_gc_safe_points"`
42- GCSafePoint uint64 `json:"gc_safe_point"`
42+ ServiceGCSafepoints []* endpoint.ServiceSafePoint `json:"service_gc_safe_points"`
43+ MinServiceGcSafepoint uint64 `json:"min_service_gc_safe_point,omitempty"`
44+ GCSafePoint uint64 `json:"gc_safe_point"`
4345}
4446
4547// @Tags service_gc_safepoint
@@ -60,9 +62,21 @@ func (h *serviceGCSafepointHandler) GetGCSafePoint(w http.ResponseWriter, r *htt
6062 h .rd .JSON (w , http .StatusInternalServerError , err .Error ())
6163 return
6264 }
65+ var minSSp * endpoint.ServiceSafePoint
66+ for _ , ssp := range ssps {
67+ if (minSSp == nil || minSSp .SafePoint > ssp .SafePoint ) &&
68+ ssp .ExpiredAt > time .Now ().Unix () {
69+ minSSp = ssp
70+ }
71+ }
72+ minServiceGcSafepoint := uint64 (0 )
73+ if minSSp != nil {
74+ minServiceGcSafepoint = minSSp .SafePoint
75+ }
6376 list := ListServiceGCSafepoint {
64- GCSafePoint : gcSafepoint ,
65- ServiceGCSafepoints : ssps ,
77+ GCSafePoint : gcSafepoint ,
78+ ServiceGCSafepoints : ssps ,
79+ MinServiceGcSafepoint : minServiceGcSafepoint ,
6680 }
6781 h .rd .JSON (w , http .StatusOK , list )
6882}
0 commit comments