Skip to content

Commit 2f404a0

Browse files
authored
fix: tolerant that node_id may be missing. (#144)
1 parent 47ac2ed commit 2f404a0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func (c *APIClient) doRequest(ctx context.Context, method, path string, req inte
243243
maxRetries := 2
244244
for i := 1; i <= maxRetries; i++ {
245245
headers, err := c.makeHeaders(ctx)
246-
if needSticky {
246+
if needSticky && len(c.NodeID) != 0 {
247247
headers.Set(DatabendQueryStickyNode, c.NodeID)
248248
}
249249
if err != nil {
@@ -511,7 +511,9 @@ func (c *APIClient) startQueryRequest(ctx context.Context, request *QueryRequest
511511
return nil, errors.Wrap(err, "failed to do query request")
512512
}
513513

514-
c.NodeID = resp.NodeID
514+
if len(resp.NodeID) != 0 {
515+
c.NodeID = resp.NodeID
516+
}
515517
c.trackStats(&resp)
516518
// try update session as long as resp is not nil, even if query failed (resp.Error != nil)
517519
// e.g. transaction state need to be updated if commit fail

0 commit comments

Comments
 (0)