diff --git a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex index b8d67208ce..7eefc7353b 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex @@ -344,6 +344,7 @@ defmodule Explorer.Chain.Import.Runner.Blocks do select: map(tb, [:address_hash, :token_contract_address_hash, :block_number]), # Enforce TokenBalance ShareLocks order (see docs: sharelocks.md) order_by: [ + tb.token_type, tb.token_contract_address_hash, tb.address_hash, tb.block_number @@ -381,6 +382,7 @@ defmodule Explorer.Chain.Import.Runner.Blocks do select: map(ctb, [:address_hash, :token_contract_address_hash]), # Enforce CurrentTokenBalance ShareLocks order (see docs: sharelocks.md) order_by: [ + ctb.token_type, ctb.token_contract_address_hash, ctb.address_hash ], diff --git a/apps/explorer/lib/explorer/chain/import/runner/tokens.ex b/apps/explorer/lib/explorer/chain/import/runner/tokens.ex index 1062a8c8bb..10e65ccf12 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/tokens.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/tokens.ex @@ -27,7 +27,10 @@ defmodule Explorer.Chain.Import.Runner.Tokens do token in Token, where: token.contract_address_hash in ^contract_address_hashes, # Enforce Token ShareLocks order (see docs: sharelocks.md) - order_by: token.contract_address_hash, + order_by: [ + token.type, + token.contract_address_hash + ], lock: "FOR UPDATE" )