Skip to content

Commit 349a070

Browse files
fix(tx_pool_throughput_analysis): handle task failure gracefully by returning early
1 parent ff30985 commit 349a070

File tree

1 file changed

+12
-6
lines changed
  • pkg/coordinator/tasks/tx_pool_throughput_analysis

1 file changed

+12
-6
lines changed

pkg/coordinator/tasks/tx_pool_throughput_analysis/task.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ func (t *Task) Execute(ctx context.Context) error {
154154
txs = append(txs, tx)
155155
}()
156156

157+
if isFailed {
158+
return;
159+
}
160+
157161
time.Sleep(sleepTime)
158162
}
159163

@@ -164,7 +168,15 @@ func (t *Task) Execute(ctx context.Context) error {
164168
lastMeasureTime := time.Now()
165169
gotTx := 0
166170

171+
if isFailed {
172+
return nil;
173+
}
174+
167175
for gotTx < t.config.QPS {
176+
if isFailed {
177+
return nil
178+
}
179+
168180
// Add a timeout of 10 seconds for reading transaction messages
169181
readChan := make(chan struct {
170182
txs *eth.TransactionsPacket
@@ -203,12 +215,6 @@ func (t *Task) Execute(ctx context.Context) error {
203215
lastMeasureTime = time.Now()
204216
}
205217

206-
if isFailed {
207-
t.logger.Errorf("Failed to execute task %v", TaskName)
208-
t.ctx.SetResult(types.TaskResultFailure)
209-
return nil
210-
}
211-
212218
totalTime := time.Since(startTime)
213219
t.logger.Infof("Total time for %d transactions: %.2fs", sentTxCount, totalTime.Seconds())
214220

0 commit comments

Comments
 (0)