Skip to content

Commit af9d2ed

Browse files
author
Mikhail Kornilov
committed
VM mod: request retry in process logs added (#219)
(cherry picked from commit eda0829)
1 parent 3cd4f7a commit af9d2ed

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

x/vm/internal/keeper/keeper_ds.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ func (k Keeper) CloseConnections() {
5959
// retryExecReq sends request with retry mechanism and waits for connection and execution.
6060
// Contract: either RawModule or RawScript must be specified for RetryExecReq.
6161
func (k Keeper) retryExecReq(ctx sdk.Context, req RetryExecReq) (retResp *vm_grpc.VMExecuteResponse, retErr error) {
62+
const failedRetryLogPeriod = 100
63+
6264
doneCh := make(chan bool)
6365
curAttempt := uint(0)
6466
reqTimeout := time.Duration(req.ReqTimeoutInMs) * time.Millisecond
@@ -98,14 +100,19 @@ func (k Keeper) retryExecReq(ctx sdk.Context, req RetryExecReq) (retResp *vm_grp
98100
return
99101
}
100102

101-
if curAttempt == req.MaxAttempts {
103+
if req.MaxAttempts != 0 && curAttempt == req.MaxAttempts {
102104
retResp, retErr = nil, err
103105
return
104106
}
105107

106108
if curReqDur < reqTimeout {
107109
time.Sleep(reqTimeout - curReqDur)
108110
}
111+
112+
if curAttempt % failedRetryLogPeriod == 0 {
113+
msg := fmt.Sprintf("Failing VM request: attempt %d / %d with %v timeout: %v", curAttempt, req.MaxAttempts, reqTimeout, time.Since(reqStartedAt))
114+
k.GetLogger(ctx).Info(msg)
115+
}
109116
}
110117
}()
111118
<-doneCh

0 commit comments

Comments
 (0)