diff --git a/core/chains/evm/logpoller/orm.go b/core/chains/evm/logpoller/orm.go index 61e0022bb5..737fb9cedc 100644 --- a/core/chains/evm/logpoller/orm.go +++ b/core/chains/evm/logpoller/orm.go @@ -404,6 +404,10 @@ func (o *DSORM) DeleteExcessLogs(ctx context.Context, limit int64) (int64, error limitClause = fmt.Sprintf(" ORDER BY block_number, log_index LIMIT %d", limit) } + // Allow SELECT query to run for up to 3 minutes. DELETE query will still have default 10s timeout + selectCtx, cancel := context.WithTimeout(sqlutil.WithoutDefaultTimeout(ctx), 3*time.Minute) + defer cancel() + query := ` WITH filters AS (SELECT name, ARRAY_AGG(address) AS addresses, ARRAY_AGG(event) AS events, @@ -424,7 +428,7 @@ func (o *DSORM) DeleteExcessLogs(ctx context.Context, limit int64) (int64, error (f.topic4 IS NULL OR l.topics[3] = ANY(f.topic4)) ) x GROUP BY id, block_number, log_index HAVING BOOL_AND(old)` + limitClause - err := o.ds.SelectContext(ctx, &rowIds, query, ubig.New(o.chainID)) + err := o.ds.SelectContext(selectCtx, &rowIds, query, ubig.New(o.chainID)) if err != nil { return 0, err } diff --git a/core/services/relay/evm/contract_transmitter.go b/core/services/relay/evm/contract_transmitter.go index 5940a62b69..80add7537c 100644 --- a/core/services/relay/evm/contract_transmitter.go +++ b/core/services/relay/evm/contract_transmitter.go @@ -116,7 +116,7 @@ func NewOCRContractTransmitter( Name: transmitterFilterName(address), EventSigs: []common.Hash{transmitted.ID}, Retention: 10 * time.Minute, - Addresses: []common.Address{address}, MaxLogsKept: 0}, + Addresses: []common.Address{address}, MaxLogsKept: 100000}, ) if err != nil { return nil, err