Skip to content

Commit b500ad4

Browse files
authored
use consistent read when deleting data (#171)
### TL;DR Added `ForceConsistentData: true` to query filters in block deletion operations. ### What changed? Modified the query filters in `deleteBlocks`, `deleteLogs`, `deleteTransactions`, and `deleteTraces` functions to include `ForceConsistentData: true` parameter when retrieving data before deletion. ### How to test? 1. Attempt to delete blocks and their associated data 2. Verify that the deletion operations complete successfully 3. Confirm that all related data (logs, transactions, traces) is consistently deleted ### Why make this change? Ensures data consistency during block deletion operations by forcing the query to return complete and consistent datasets before performing deletions. This prevents potential partial or inconsistent data deletions that could corrupt the database state.
2 parents 0b05930 + 1f32c29 commit b500ad4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

internal/storage/clickhouse.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,8 +1039,9 @@ func (c *ClickHouseConnector) DeleteBlockData(chainId *big.Int, blockNumbers []*
10391039

10401040
func (c *ClickHouseConnector) deleteBlocks(chainId *big.Int, blockNumbers []*big.Int) error {
10411041
blocksQueryResult, err := c.GetBlocks(QueryFilter{
1042-
ChainId: chainId,
1043-
BlockNumbers: blockNumbers,
1042+
ChainId: chainId,
1043+
BlockNumbers: blockNumbers,
1044+
ForceConsistentData: true,
10441045
}, "*")
10451046
if err != nil {
10461047
return err
@@ -1055,8 +1056,9 @@ func (c *ClickHouseConnector) deleteBlocks(chainId *big.Int, blockNumbers []*big
10551056

10561057
func (c *ClickHouseConnector) deleteLogs(chainId *big.Int, blockNumbers []*big.Int) error {
10571058
logsQueryResult, err := c.GetLogs(QueryFilter{
1058-
ChainId: chainId,
1059-
BlockNumbers: blockNumbers,
1059+
ChainId: chainId,
1060+
BlockNumbers: blockNumbers,
1061+
ForceConsistentData: true,
10601062
}, "*")
10611063
if err != nil {
10621064
return err
@@ -1071,8 +1073,9 @@ func (c *ClickHouseConnector) deleteLogs(chainId *big.Int, blockNumbers []*big.I
10711073

10721074
func (c *ClickHouseConnector) deleteTransactions(chainId *big.Int, blockNumbers []*big.Int) error {
10731075
txsQueryResult, err := c.GetTransactions(QueryFilter{
1074-
ChainId: chainId,
1075-
BlockNumbers: blockNumbers,
1076+
ChainId: chainId,
1077+
BlockNumbers: blockNumbers,
1078+
ForceConsistentData: true,
10761079
}, "*")
10771080
if err != nil {
10781081
return err
@@ -1087,8 +1090,9 @@ func (c *ClickHouseConnector) deleteTransactions(chainId *big.Int, blockNumbers
10871090

10881091
func (c *ClickHouseConnector) deleteTraces(chainId *big.Int, blockNumbers []*big.Int) error {
10891092
tracesQueryResult, err := c.GetTraces(QueryFilter{
1090-
ChainId: chainId,
1091-
BlockNumbers: blockNumbers,
1093+
ChainId: chainId,
1094+
BlockNumbers: blockNumbers,
1095+
ForceConsistentData: true,
10921096
}, "*")
10931097
if err != nil {
10941098
return err

0 commit comments

Comments
 (0)