Fix datarace condition
By creating local variables within each goroutine.
This commit is contained in:
parent
72eea46bab
commit
64a89d8a46
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ temp/*
|
|||||||
pkg/beaconclient/ssz-data/
|
pkg/beaconclient/ssz-data/
|
||||||
*.test
|
*.test
|
||||||
ipld-eth-beacon-indexer.log
|
ipld-eth-beacon-indexer.log
|
||||||
|
config/local.ipld-eth-beacon-indexer-config.json
|
||||||
|
@ -545,7 +545,6 @@ func IsSlotInDb(ctx context.Context, db sql.Database, slot string, blockRoot str
|
|||||||
var (
|
var (
|
||||||
isInBeaconState bool
|
isInBeaconState bool
|
||||||
isInSignedBeaconBlock bool
|
isInSignedBeaconBlock bool
|
||||||
err error
|
|
||||||
)
|
)
|
||||||
errG, _ := errgroup.WithContext(context.Background())
|
errG, _ := errgroup.WithContext(context.Background())
|
||||||
errG.Go(func() error {
|
errG.Go(func() error {
|
||||||
@ -553,6 +552,7 @@ func IsSlotInDb(ctx context.Context, db sql.Database, slot string, blockRoot str
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
|
var err error
|
||||||
isInBeaconState, err = checkSlotAndRoot(db, CheckBeaconStateStmt, slot, stateRoot)
|
isInBeaconState, err = checkSlotAndRoot(db, CheckBeaconStateStmt, slot, stateRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
loghelper.LogError(err).Error("Unable to check if the slot and stateroot exist in eth_beacon.state")
|
loghelper.LogError(err).Error("Unable to check if the slot and stateroot exist in eth_beacon.state")
|
||||||
@ -565,6 +565,7 @@ func IsSlotInDb(ctx context.Context, db sql.Database, slot string, blockRoot str
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
|
var err error
|
||||||
isInSignedBeaconBlock, err = checkSlotAndRoot(db, CheckSignedBeaconBlockStmt, slot, blockRoot)
|
isInSignedBeaconBlock, err = checkSlotAndRoot(db, CheckSignedBeaconBlockStmt, slot, blockRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
loghelper.LogError(err).Error("Unable to check if the slot and block_root exist in eth_beacon.signed_block")
|
loghelper.LogError(err).Error("Unable to check if the slot and block_root exist in eth_beacon.signed_block")
|
||||||
|
Loading…
Reference in New Issue
Block a user