Skip to content

Commit

Permalink
take query timeout set at session into account
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <[email protected]>
  • Loading branch information
harshit-gangal committed Sep 9, 2024
1 parent 4451119 commit 7e01664
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions go/vt/vtgate/vcursor_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,15 +930,26 @@ func (vc *vcursorImpl) SetPriority(priority string) {
}

func (vc *vcursorImpl) SetExecQueryTimeout(timeout *int) {
if timeout == nil {
// Determine the effective timeout: use passed timeout if non-nil, otherwise use session's query timeout if available
var execTimeout *int
if timeout != nil {
execTimeout = timeout
} else if sessionTimeout := int(vc.safeSession.GetQueryTimeout()); sessionTimeout > 0 {
execTimeout = &sessionTimeout
}

// If no effective timeout and no session options, return early
if execTimeout == nil {
if vc.safeSession.GetOptions() == nil {
return
}
vc.safeSession.GetOrCreateOptions().Timeout = nil
return
}

// Set the authoritative timeout using the determined execTimeout
vc.safeSession.GetOrCreateOptions().Timeout = &querypb.ExecuteOptions_AuthoritativeTimeout{
AuthoritativeTimeout: int64(*timeout),
AuthoritativeTimeout: int64(*execTimeout),
}
}

Expand Down

0 comments on commit 7e01664

Please sign in to comment.