Skip to content

Commit

Permalink
fix: edge case crash during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPiechota committed Jan 23, 2025
1 parent 9365c3e commit f2a8cd7
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions apps/arweave/src/ar_mining_io.erl
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,23 @@ start_io_thread(Mode, StoreIDs) ->
map_partition_to_store_ids([], PartitionToStoreIDs) ->
PartitionToStoreIDs;
map_partition_to_store_ids([StoreID | StoreIDs], PartitionToStoreIDs) ->
StorageModule = ar_storage_module:get_by_id(StoreID),
{Start, End} = ar_storage_module:module_range(StorageModule, 0),
Partitions = get_store_id_partitions({Start, End}, []),
PartitionToStoreIDs2 = lists:foldl(
fun(Partition, Acc) ->
maps:update_with(Partition,
fun(PartitionStoreIDs) -> [StoreID | PartitionStoreIDs] end,
[StoreID], Acc)
end,
PartitionToStoreIDs, Partitions),
map_partition_to_store_ids(StoreIDs, PartitionToStoreIDs2).
case ar_storage_module:get_by_id(StoreID) of
not_found ->
%% Occasionally happens in tests.
?LOG_ERROR([{event, mining_storage_module_not_found}, {store_id, StoreID}]),
map_partition_to_store_ids(StoreIDs, PartitionToStoreIDs);
StorageModule ->
{Start, End} = ar_storage_module:module_range(StorageModule, 0),
Partitions = get_store_id_partitions({Start, End}, []),
PartitionToStoreIDs2 = lists:foldl(
fun(Partition, Acc) ->
maps:update_with(Partition,
fun(PartitionStoreIDs) -> [StoreID | PartitionStoreIDs] end,
[StoreID], Acc)
end,
PartitionToStoreIDs, Partitions),
map_partition_to_store_ids(StoreIDs, PartitionToStoreIDs2)
end.

get_store_id_partitions({Start, End}, Partitions) when Start >= End ->
Partitions;
Expand Down

0 comments on commit f2a8cd7

Please sign in to comment.