Skip to content

Commit

Permalink
fix(db): add context-timeout to findExecBlockNumbersByExecBlockNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush committed Jan 14, 2025
1 parent 1af1273 commit 82e8336
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion handlers/api_eth1.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package handlers

import (
"context"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"math/big"
"net/http"
Expand Down Expand Up @@ -693,7 +695,9 @@ func findExecBlockNumbersByFeeRecipient(addresses [][]byte, offset, limit uint64

func findExecBlockNumbersByExecBlockNumber(execBlocks []uint64, offset, limit uint64) ([]uint64, map[uint64]types.ExecBlockProposer, error) {
var blockListSub []types.ExecBlockProposer
err := db.ReaderDb.Select(&blockListSub,
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
err := db.ReaderDb.SelectContext(ctx, &blockListSub,
`SELECT
exec_block_number,
proposer,
Expand All @@ -709,6 +713,9 @@ func findExecBlockNumbersByExecBlockNumber(execBlocks []uint64, offset, limit ui
offset,
limit,
)
if errors.Is(err, context.DeadlineExceeded) {
logger.Errorf("LONG_RUNNING_POSTGRES_READ: db.findExecBlockNumbersByExecBlockNumber: retrieving data took longer than 10s with params: execBlocks: %v, offset: %v, limit: %v: %v", execBlocks, offset, limit, err)
}
if err != nil {
return nil, nil, err
}
Expand Down

0 comments on commit 82e8336

Please sign in to comment.