Skip to content

Commit 016e110

Browse files
committed
retry InitSearchAttribute
Signed-off-by: Stephan Behnke <[email protected]>
1 parent 16d3304 commit 016e110

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

loadgen/workflow_completion_verifier.go

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,44 @@ func (wct *WorkflowCompletionVerifier) init(ctx context.Context, info ScenarioIn
4747
return nil
4848
}
4949

50+
// Retry InitSearchAttribute until context deadline expires
51+
retryTicker := time.NewTicker(2 * time.Second)
52+
defer retryTicker.Stop()
53+
54+
// Try immediately first
55+
var lastErr error
5056
if err := InitSearchAttribute(ctx, info, OmesExecutionIDSearchAttribute); err != nil {
51-
return fmt.Errorf("failed to register search attribute %s: %w",
57+
lastErr = err
58+
info.Logger.Warnf("failed to register search attribute %s, will retry: %v",
5259
OmesExecutionIDSearchAttribute, err)
60+
} else {
61+
return nil
62+
}
63+
64+
// Retry loop until context deadline
65+
for {
66+
select {
67+
case <-ctx.Done():
68+
// Context ended (deadline or cancellation). Return last error.
69+
return fmt.Errorf("failed to register search attribute %s after retries: %w",
70+
OmesExecutionIDSearchAttribute, lastErr)
71+
case <-retryTicker.C:
72+
// Don't perform retry if context is already done
73+
if ctx.Err() != nil {
74+
return fmt.Errorf("failed to register search attribute %s after retries: %w",
75+
OmesExecutionIDSearchAttribute, lastErr)
76+
}
77+
if err := InitSearchAttribute(ctx, info, OmesExecutionIDSearchAttribute); err != nil {
78+
lastErr = err
79+
info.Logger.Warnf("failed to register search attribute %s, will retry: %v",
80+
OmesExecutionIDSearchAttribute, err)
81+
} else {
82+
info.Logger.Infof("successfully registered search attribute %s after retries",
83+
OmesExecutionIDSearchAttribute)
84+
return nil
85+
}
86+
}
5387
}
54-
return nil
5588
}
5689

5790
// VerifyRun implements the Verifier interface.

0 commit comments

Comments
 (0)