Order derive_tranactions_forks SELECT to match transaction inserts

Fixes #1311

Prevent deadlocks due to order in the `SELECT transaction` for
`Explorer.Chain.Import.Runner.Blocks.derived_transaction_forks` differing from
order in `Explorer.Chain.Import.Runner.Transactions.insert` by sorting
both by hash ascending.
pull/1318/head
Luke Imhoff 6 years ago
parent 02a1b46e26
commit f016475f1d
  1. 5
      apps/explorer/lib/explorer/chain/import/runner/blocks.ex

@ -129,7 +129,10 @@ defmodule Explorer.Chain.Import.Runner.Blocks do
transaction.hash,
type(^inserted_at, transaction.inserted_at),
type(^updated_at, transaction.updated_at)
]
],
# order so that row ShareLocks are grabbed in a consistent order with
# `Explorer.Chain.Import.Runner.Transactions.insert`
order_by: transaction.hash
)
{select_sql, parameters} = SQL.to_sql(:all, repo, query)

Loading…
Cancel
Save