Skip to content

Conversation

@iuwqyir
Copy link
Contributor

@iuwqyir iuwqyir commented May 14, 2025

TL;DR

Changed the map key type in ReplaceBlockData from *big.Int to string to fix potential memory issues.

What changed?

Modified the deletedBlockDataByNumber map in the ReplaceBlockData function to use string keys instead of *big.Int pointers. All map operations now convert the block numbers to strings using the .String() method before using them as keys.

How to test?

  1. Run the application with a scenario that triggers the ReplaceBlockData function
  2. Verify that block data replacement works correctly
  3. Check that there are no memory leaks or unexpected behavior when handling multiple blocks

Why make this change?

Using *big.Int as map keys can lead to unexpected behavior because equality for pointers is based on memory address, not the actual numeric value. Two different *big.Int pointers with the same numeric value would be treated as different keys. Converting to strings ensures that blocks with the same number are properly identified and handled, preventing potential data inconsistencies and memory issues.

Copy link
Contributor Author

iuwqyir commented May 14, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@iuwqyir iuwqyir requested review from AmineAfia and catalyst17 May 14, 2025 21:23
@iuwqyir iuwqyir marked this pull request as ready for review May 14, 2025 21:23
@iuwqyir iuwqyir changed the base branch from 05-14-handle_clickhouse_errors_during_inserts to graphite-base/196 May 15, 2025 09:33
@iuwqyir iuwqyir force-pushed the 05-15-fix_mapping_keys_when_replacing_data branch from 0de130e to 8dbd642 Compare May 15, 2025 09:33
@graphite-app graphite-app bot changed the base branch from graphite-base/196 to main May 15, 2025 09:33
@iuwqyir iuwqyir force-pushed the 05-15-fix_mapping_keys_when_replacing_data branch from 8dbd642 to 10f868f Compare May 15, 2025 09:33
@iuwqyir iuwqyir merged commit e5f7511 into main May 15, 2025
5 checks passed
@iuwqyir iuwqyir deleted the 05-15-fix_mapping_keys_when_replacing_data branch May 15, 2025 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants