Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion x/vm/internal/keeper/keeper_ds.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func (k Keeper) CloseConnections() {
// retryExecReq sends request with retry mechanism and waits for connection and execution.
// Contract: either RawModule or RawScript must be specified for RetryExecReq.
func (k Keeper) retryExecReq(ctx sdk.Context, req RetryExecReq) (retResp *vm_grpc.VMExecuteResponse, retErr error) {
const failedRetryLogPeriod = 100

doneCh := make(chan bool)
curAttempt := uint(0)
reqTimeout := time.Duration(req.ReqTimeoutInMs) * time.Millisecond
Expand Down Expand Up @@ -98,14 +100,19 @@ func (k Keeper) retryExecReq(ctx sdk.Context, req RetryExecReq) (retResp *vm_grp
return
}

if curAttempt == req.MaxAttempts {
if req.MaxAttempts != 0 && curAttempt == req.MaxAttempts {
retResp, retErr = nil, err
return
}

if curReqDur < reqTimeout {
time.Sleep(reqTimeout - curReqDur)
}

if curAttempt % failedRetryLogPeriod == 0 {
msg := fmt.Sprintf("Failing VM request: attempt %d / %d with %v timeout: %v", curAttempt, req.MaxAttempts, reqTimeout, time.Since(reqStartedAt))
k.GetLogger(ctx).Info(msg)
}
}
}()
<-doneCh
Expand Down