-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: support resigning ddl owner, use http method ddl/owner/resign #7649
Changes from all commits
8453481
3ac8bfa
0e10bb0
91406bc
861a528
3e1481c
aa218ae
30172e0
c90f2c5
e7c24f0
d12ce8d
e3f88d2
24cdaf7
e376c2b
d94720a
b89de26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,6 +334,11 @@ type ddlHistoryJobHandler struct { | |
*tikvHandlerTool | ||
} | ||
|
||
// ddlResignOwnerHandler is the handler for resigning ddl owner. | ||
type ddlResignOwnerHandler struct { | ||
store kv.Storage | ||
} | ||
|
||
type serverInfoHandler struct { | ||
*tikvHandlerTool | ||
} | ||
|
@@ -713,6 +718,37 @@ func (h ddlHistoryJobHandler) ServeHTTP(w http.ResponseWriter, req *http.Request | |
return | ||
} | ||
|
||
func (h ddlResignOwnerHandler) resignDDLOwner() error { | ||
dom, err := session.GetDomain(h.store) | ||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
|
||
ownerMgr := dom.DDL().OwnerManager() | ||
err = ownerMgr.ResignOwner(context.Background()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to add a timeout? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @winkyao Please answer this question. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, PTAL |
||
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
return nil | ||
} | ||
|
||
// ServeHTTP handles request of resigning ddl owner. | ||
func (h ddlResignOwnerHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { | ||
if req.Method != http.MethodPost { | ||
writeError(w, errors.Errorf("This api only support POST method.")) | ||
return | ||
} | ||
|
||
err := h.resignDDLOwner() | ||
if err != nil { | ||
log.Error(err) | ||
writeError(w, err) | ||
return | ||
} | ||
|
||
writeData(w, "success!") | ||
} | ||
|
||
func (h tableHandler) getPDAddr() ([]string, error) { | ||
var pdAddrs []string | ||
etcd, ok := h.store.(domain.EtcdBackend) | ||
|
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.
Can we call
RetireOwner
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.
No, this is not the work of ResignOwner.