Skip to content

Commit

Permalink
(BIDS-1402) Always check return value of bigtable.tableData.ReadRows …
Browse files Browse the repository at this point in the history
…(which is err)
  • Loading branch information
recy21 committed Jan 17, 2023
1 parent 391a194 commit 140f4d8
Showing 1 changed file with 48 additions and 9 deletions.
57 changes: 48 additions & 9 deletions db/bigtable_eth1.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,13 @@ func (bigtable *Bigtable) DeleteRowsWithPrefix(prefix string) {
rr := gcp_bigtable.InfiniteRange(prefix)

rowsToDelete := make([]string, 0, 10000)
bigtable.tableData.ReadRows(ctx, rr, func(r gcp_bigtable.Row) bool {
err := bigtable.tableData.ReadRows(ctx, rr, func(r gcp_bigtable.Row) bool {
rowsToDelete = append(rowsToDelete, r.Key())
return true
})
if err != nil {
logger.WithError(err).WithField("prefix", prefix).Errorf("error reading rows in bigtable_eth1 / DeleteRowsWithPrefix")
}
mut := gcp_bigtable.NewMutation()
mut.DeleteRow()

Expand Down Expand Up @@ -1685,7 +1688,7 @@ func (bigtable *Bigtable) GetEth1TxForAddress(prefix string, limit int64) ([]*ty
return data, "", nil
}

bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
err = bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
b := &types.Eth1TransactionIndexed{}
err := proto.Unmarshal(row[DEFAULT_FAMILY][0].Value, b)

Expand All @@ -1696,6 +1699,11 @@ func (bigtable *Bigtable) GetEth1TxForAddress(prefix string, limit int64) ([]*ty

return true
})
if err != nil {
logger.WithError(err).WithField("prefix", prefix).WithField("limit", limit).Errorf("error reading rows in bigtable_eth1 / GetEth1TxForAddress")
return nil, "", err
}

// logger.Infof("adding keys: %+v", keys)
// logger.Infof("adding indexes: %+v", indexes)
for _, key := range keys {
Expand Down Expand Up @@ -1844,7 +1852,7 @@ func (bigtable *Bigtable) GetEth1BlocksForAddress(prefix string, limit int64) ([
return data, "", nil
}

bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
err = bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
b := &types.Eth1BlockIndexed{}
err := proto.Unmarshal(row[DEFAULT_FAMILY][0].Value, b)

Expand All @@ -1855,6 +1863,11 @@ func (bigtable *Bigtable) GetEth1BlocksForAddress(prefix string, limit int64) ([

return true
})
if err != nil {
logger.WithError(err).WithField("prefix", prefix).WithField("limit", limit).Errorf("error reading rows in bigtable_eth1 / GetEth1BlocksForAddress")
return nil, "", err
}

// logger.Infof("adding keys: %+v", keys)
// logger.Infof("adding indexes: %+v", indexes)
for _, key := range keys {
Expand Down Expand Up @@ -1929,7 +1942,7 @@ func (bigtable *Bigtable) GetEth1UnclesForAddress(prefix string, limit int64) ([
return data, "", nil
}

bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
err = bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
b := &types.Eth1UncleIndexed{}
err := proto.Unmarshal(row[DEFAULT_FAMILY][0].Value, b)

Expand All @@ -1940,6 +1953,11 @@ func (bigtable *Bigtable) GetEth1UnclesForAddress(prefix string, limit int64) ([

return true
})
if err != nil {
logger.WithError(err).WithField("prefix", prefix).WithField("limit", limit).Errorf("error reading rows in bigtable_eth1 / GetEth1UnclesForAddress")
return nil, "", err
}

// logger.Infof("adding keys: %+v", keys)
// logger.Infof("adding indexes: %+v", indexes)
for _, key := range keys {
Expand Down Expand Up @@ -2007,7 +2025,7 @@ func (bigtable *Bigtable) GetEth1ItxForAddress(prefix string, address []byte, li
return data, "", nil
}

bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
err = bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
b := &types.Eth1InternalTransactionIndexed{}
err := proto.Unmarshal(row[DEFAULT_FAMILY][0].Value, b)

Expand All @@ -2022,6 +2040,10 @@ func (bigtable *Bigtable) GetEth1ItxForAddress(prefix string, address []byte, li
keysMap[row.Key()] = b
return true
})
if err != nil {
logger.WithError(err).WithField("prefix", prefix).WithField("limit", limit).WithField("address", address).Errorf("error reading rows in bigtable_eth1 / GetEth1ItxForAddress")
return nil, "", err
}

for _, key := range keys {
if d := keysMap[key]; d != nil {
Expand Down Expand Up @@ -2289,7 +2311,7 @@ func (bigtable *Bigtable) GetEth1ERC20ForAddress(prefix string, limit int64) ([]
return data, "", nil
}

bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
err = bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
b := &types.Eth1ERC20Indexed{}
err := proto.Unmarshal(row[DEFAULT_FAMILY][0].Value, b)

Expand All @@ -2299,6 +2321,10 @@ func (bigtable *Bigtable) GetEth1ERC20ForAddress(prefix string, limit int64) ([]
keysMap[row.Key()] = b
return true
})
if err != nil {
logger.WithError(err).WithField("prefix", prefix).WithField("limit", limit).Errorf("error reading rows in bigtable_eth1 / GetEth1ERC20ForAddress")
return nil, "", err
}

for _, key := range keys {
data = append(data, keysMap[key])
Expand Down Expand Up @@ -2398,7 +2424,7 @@ func (bigtable *Bigtable) GetEth1ERC721ForAddress(prefix string, limit int64) ([
return data, "", nil
}

bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
err = bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
b := &types.Eth1ERC721Indexed{}
err := proto.Unmarshal(row[DEFAULT_FAMILY][0].Value, b)

Expand All @@ -2408,6 +2434,10 @@ func (bigtable *Bigtable) GetEth1ERC721ForAddress(prefix string, limit int64) ([
keysMap[row.Key()] = b
return true
})
if err != nil {
logger.WithError(err).WithField("prefix", prefix).WithField("limit", limit).Errorf("error reading rows in bigtable_eth1 / GetEth1ERC721ForAddress")
return nil, "", err
}

for _, key := range keys {
data = append(data, keysMap[key])
Expand Down Expand Up @@ -2480,7 +2510,7 @@ func (bigtable *Bigtable) GetEth1ERC1155ForAddress(prefix string, limit int64) (
return data, "", nil
}

bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
err = bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
b := &types.ETh1ERC1155Indexed{}
err := proto.Unmarshal(row[DEFAULT_FAMILY][0].Value, b)

Expand All @@ -2490,6 +2520,10 @@ func (bigtable *Bigtable) GetEth1ERC1155ForAddress(prefix string, limit int64) (
keysMap[row.Key()] = b
return true
})
if err != nil {
logger.WithError(err).WithField("prefix", prefix).WithField("limit", limit).Errorf("error reading rows in bigtable_eth1 / GetEth1ERC1155ForAddress")
return nil, "", err
}

for _, key := range keys {
data = append(data, keysMap[key])
Expand Down Expand Up @@ -3164,7 +3198,7 @@ func (bigtable *Bigtable) GetEth1TxForToken(prefix string, limit int64) ([]*type
return data, "", nil
}

bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
err = bigtable.tableData.ReadRows(ctx, gcp_bigtable.RowList(keys), func(row gcp_bigtable.Row) bool {
b := &types.Eth1ERC20Indexed{}
err := proto.Unmarshal(row[DEFAULT_FAMILY][0].Value, b)

Expand All @@ -3175,6 +3209,11 @@ func (bigtable *Bigtable) GetEth1TxForToken(prefix string, limit int64) ([]*type

return true
})
if err != nil {
logger.WithError(err).WithField("prefix", prefix).WithField("limit", limit).Errorf("error reading rows in bigtable_eth1 / GetEth1TxForToken")
return nil, "", err
}

// logger.Infof("adding keys: %+v", keys)
// logger.Infof("adding indexes: %+v", indexes)
for _, key := range keys {
Expand Down

0 comments on commit 140f4d8

Please sign in to comment.