Skip to content

Commit 87a56fd

Browse files
committed
fix: support ExecContext cancel query
1 parent 0e43f54 commit 87a56fd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

restful.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,14 @@ func (c *APIClient) PollUntilQueryEnd(ctx context.Context, resp *QueryResponse)
377377
data := resp.Data
378378
resp, err = c.PollQuery(ctx, resp.NextURI)
379379
if err != nil {
380+
if errors.Is(err, context.Canceled) {
381+
// context might be canceled due to timeout or canceled. if it's canceled, we need call
382+
// the kill url to tell the backend it's killed.
383+
fmt.Printf("query canceled, kill query:%s", resp.ID)
384+
_ = c.KillQuery(context.Background(), resp)
385+
} else {
386+
_ = c.CloseQuery(ctx, resp)
387+
}
380388
return nil, err
381389
}
382390
if resp.Error != nil {

0 commit comments

Comments
 (0)