Skip to content

Commit

Permalink
Prevent blockprocess internal wait dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicletz committed Jan 28, 2024
1 parent 00ad997 commit e43d0c5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/block_process.ex
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ defmodule BlockProcess do
end
end

def watch(me) do
@tick 30_000
def watch(me, secs \\ 0) do
receive do
:stop -> :ok
after
30000 ->
Logger.warn("Long running block process: #{inspect({me, Profiler.stacktrace(me)})}")
watch(me)
@tick ->
dump = inspect({me, Profiler.stacktrace(me)})
secs = secs + div(@tick, 1000)
Logger.warn("Long running block process #{secs}s: #{dump}")
watch(me, secs)
end
end

Expand Down Expand Up @@ -345,7 +348,9 @@ defmodule BlockProcess do
fun.(Worker.block())

true ->
do_with_worker(block_hash, fn block -> block end, timeout)
Stats.tc(:sql_block_by_hash, fn ->
Model.ChainSql.block_by_hash(block_hash)
end)
|> with_block(fun, timeout)
end
end
Expand Down

0 comments on commit e43d0c5

Please sign in to comment.