Skip to content

Commit

Permalink
fix: tolerant that node_id may be missing. (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
youngsofun authored Dec 11, 2024
1 parent 47ac2ed commit 2f404a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (c *APIClient) doRequest(ctx context.Context, method, path string, req inte
maxRetries := 2
for i := 1; i <= maxRetries; i++ {
headers, err := c.makeHeaders(ctx)
if needSticky {
if needSticky && len(c.NodeID) != 0 {
headers.Set(DatabendQueryStickyNode, c.NodeID)
}
if err != nil {
Expand Down Expand Up @@ -511,7 +511,9 @@ func (c *APIClient) startQueryRequest(ctx context.Context, request *QueryRequest
return nil, errors.Wrap(err, "failed to do query request")
}

c.NodeID = resp.NodeID
if len(resp.NodeID) != 0 {
c.NodeID = resp.NodeID
}
c.trackStats(&resp)
// try update session as long as resp is not nil, even if query failed (resp.Error != nil)
// e.g. transaction state need to be updated if commit fail
Expand Down

0 comments on commit 2f404a0

Please sign in to comment.