You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
handle false positive clickhouse errors during inserts (#195)
### TL;DR
Added error handling for block data insertion that checks if data was actually inserted despite reported errors.
### What changed?
- Added a new `getMaxBlockNumberConsistent` method that retrieves the maximum block number with sequential consistency guarantees
- Enhanced the `InsertBlockData` error handling to verify if data was actually inserted despite reported errors
- When an error occurs during batch insertion, the code now:
1. Determines the highest block number in the batch
2. Waits briefly (500ms)
3. Checks if the highest block from the batch matches the max consistent block in the database
4. Only returns an error if the verification fails, otherwise logs the error but continues execution
### How to test?
1. Trigger a scenario where ClickHouse reports an error during batch insertion but actually inserts the data
2. Verify that the process continues execution rather than failing
3. Check logs for the message "Failure while inserting block data, but insert still succeeded"
### Why make this change?
ClickHouse can sometimes report errors during batch insertions even when the data was successfully inserted in the background. This change prevents unnecessary failures by verifying the actual state of the database before deciding whether to propagate the error, improving the reliability of the indexer.
query:=fmt.Sprintf("SELECT block_number FROM %s.%s WHERE chain_id = ? ORDER BY block_number DESC LIMIT 1 SETTINGS select_sequential_consistency = 1", c.cfg.Database, tableName)
0 commit comments