From 0dd93360f19170883a7355531954dd7025392d2a Mon Sep 17 00:00:00 2001 From: ttt161 Date: Thu, 6 Aug 2026 11:26:36 +0300 Subject: [PATCH 1/2] define woody deadline with process_step_timeout --- apps/prg_machine/src/prg_machine.erl | 26 ++++++++++++-------------- rebar.config | 2 +- rebar.lock | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/apps/prg_machine/src/prg_machine.erl b/apps/prg_machine/src/prg_machine.erl index 7a6137c3..126c592a 100644 --- a/apps/prg_machine/src/prg_machine.erl +++ b/apps/prg_machine/src/prg_machine.erl @@ -52,7 +52,7 @@ -type process_options() :: #{ ns := namespace(), - default_handling_timeout => timeout() + handling_timeout := timeout() }. -export_type([ @@ -299,17 +299,15 @@ process({CallType, BinArgs, Process}, #{ns := NS} = Opts, BinCtx) -> {error, Exception} end. -%% Default woody deadline (30s, configurable per namespace via opts), restoring the -%% old hg_progressor behaviour (hg_woody_service_wrapper:ensure_woody_deadline_set/2). --define(DEFAULT_HANDLING_TIMEOUT, 30000). - ensure_deadline_set(WoodyCtx, Opts) -> + Timeout = maps:get(handling_timeout, Opts), + MaxDeadline = woody_deadline:from_timeout(Timeout), case woody_context:get_deadline(WoodyCtx) of undefined -> - Timeout = maps:get(default_handling_timeout, Opts, ?DEFAULT_HANDLING_TIMEOUT), - woody_context:set_deadline(woody_deadline:from_timeout(Timeout), WoodyCtx); - _Set -> - WoodyCtx + woody_context:set_deadline(MaxDeadline, WoodyCtx); + Deadline -> + %% deadline must not exceed the value process_step_timeout from namespace options + woody_context:set_deadline(min(Deadline, MaxDeadline), WoodyCtx) end. %% Event-sourcing @@ -598,7 +596,7 @@ context_binding_scopes_process(Scope) -> hellgate -> ?TEST_NS; fistful -> ?TEST_FF_NS end, - ?assertMatch({ok, _}, run_env_hook_process(#{ns => NS})), + ?assertMatch({ok, _}, run_env_hook_process(#{ns => NS, handling_timeout => 5000})), ?assertEqual([{context_bound, Scope}], prg_machine_env_mock_context:events()). -spec setup_env_hook_test() -> ok. @@ -685,7 +683,7 @@ collapse_survives_non_map_aux_state() -> -spec business_exception_then_signal_does_not_corrupt_aux_state() -> _. business_exception_then_signal_does_not_corrupt_aux_state() -> - Opts = #{ns => ?AUX_STATE_TEST_NS}, + Opts = #{ns => ?AUX_STATE_TEST_NS, handling_timeout => 5000}, Process0 = #{ process_id => <<"invoice-exception-test">>, last_event_id => 0, @@ -719,7 +717,7 @@ business_exception_then_signal_does_not_corrupt_aux_state() -> -spec notify_noop_omits_aux_state() -> _. notify_noop_omits_aux_state() -> - Opts = #{ns => ?AUX_STATE_TEST_NS}, + Opts = #{ns => ?AUX_STATE_TEST_NS, handling_timeout => 5000}, AuxBin = prg_machine_aux_state_test_handler:marshal_aux_state(#{model => initialized}), Process = #{ process_id => <<"notify-test">>, @@ -748,7 +746,7 @@ lookup_unknown_namespace_returns_error() -> -spec process_unknown_namespace_returns_error() -> _. process_unknown_namespace_returns_error() -> - Opts = #{ns => unknown_ns}, + Opts = #{ns => unknown_ns, handling_timeout => 5000}, Process = #{ process_id => <<"unknown-ns-test">>, last_event_id => 0, @@ -762,7 +760,7 @@ process_unknown_namespace_returns_error() -> -spec process_crash_conforms_progressor_exception() -> _. process_crash_conforms_progressor_exception() -> - Opts = #{ns => ?AUX_STATE_TEST_NS}, + Opts = #{ns => ?AUX_STATE_TEST_NS, handling_timeout => 5000}, Process = #{ process_id => <<"crash-test">>, last_event_id => 0, diff --git a/rebar.config b/rebar.config index b074aa78..e8f4c7ef 100644 --- a/rebar.config +++ b/rebar.config @@ -47,7 +47,7 @@ {fault_detector_proto, {git, "https://github.com/valitydev/fault-detector-proto.git", {branch, "master"}}}, {limiter_proto, {git, "https://github.com/valitydev/limiter-proto.git", {tag, "v2.1.1"}}}, {herd, {git, "https://github.com/wgnet/herd.git", {tag, "1.3.4"}}}, - {progressor, {git, "https://github.com/valitydev/progressor.git", {tag, "v1.0.25"}}}, + {progressor, {git, "https://github.com/valitydev/progressor.git", {tag, "v1.0.27"}}}, {machinery, {git, "https://github.com/valitydev/machinery-erlang.git", {tag, "v1.1.22"}}}, {fistful_proto, {git, "https://github.com/valitydev/fistful-proto.git", {branch, "master"}}}, {binbase_proto, {git, "https://github.com/valitydev/binbase-proto.git", {branch, "master"}}}, diff --git a/rebar.lock b/rebar.lock index f46a494f..5f6f7417 100644 --- a/rebar.lock +++ b/rebar.lock @@ -121,7 +121,7 @@ 0}, {<<"progressor">>, {git,"https://github.com/valitydev/progressor.git", - {ref,"8624e58627e33633e6eb72c5b9defb208b06a169"}}, + {ref,"cb8ab2d88b4a49bf521647899eb4e72a24d53026"}}, 0}, {<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.11.0">>},0}, {<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.9">>},0}, From 15d243c88cfe8737577c949d24160a4e412d6064 Mon Sep 17 00:00:00 2001 From: ttt161 Date: Thu, 6 Aug 2026 12:07:17 +0300 Subject: [PATCH 2/2] fix issue --- apps/prg_machine/src/prg_machine.erl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/prg_machine/src/prg_machine.erl b/apps/prg_machine/src/prg_machine.erl index 126c592a..ac960fb8 100644 --- a/apps/prg_machine/src/prg_machine.erl +++ b/apps/prg_machine/src/prg_machine.erl @@ -555,6 +555,7 @@ map_client_error(_Type, _NS, Error) -> -define(TEST_NS, env_test_ns). -define(TEST_FF_NS, 'ff/env_test_ns'). -define(TABLE, prg_machine_dispatch). +-define(TEST_TIMEOUT, 5000). -spec test() -> _. @@ -596,7 +597,7 @@ context_binding_scopes_process(Scope) -> hellgate -> ?TEST_NS; fistful -> ?TEST_FF_NS end, - ?assertMatch({ok, _}, run_env_hook_process(#{ns => NS, handling_timeout => 5000})), + ?assertMatch({ok, _}, run_env_hook_process(#{ns => NS, handling_timeout => ?TEST_TIMEOUT})), ?assertEqual([{context_bound, Scope}], prg_machine_env_mock_context:events()). -spec setup_env_hook_test() -> ok. @@ -683,7 +684,7 @@ collapse_survives_non_map_aux_state() -> -spec business_exception_then_signal_does_not_corrupt_aux_state() -> _. business_exception_then_signal_does_not_corrupt_aux_state() -> - Opts = #{ns => ?AUX_STATE_TEST_NS, handling_timeout => 5000}, + Opts = #{ns => ?AUX_STATE_TEST_NS, handling_timeout => ?TEST_TIMEOUT}, Process0 = #{ process_id => <<"invoice-exception-test">>, last_event_id => 0, @@ -717,7 +718,7 @@ business_exception_then_signal_does_not_corrupt_aux_state() -> -spec notify_noop_omits_aux_state() -> _. notify_noop_omits_aux_state() -> - Opts = #{ns => ?AUX_STATE_TEST_NS, handling_timeout => 5000}, + Opts = #{ns => ?AUX_STATE_TEST_NS, handling_timeout => ?TEST_TIMEOUT}, AuxBin = prg_machine_aux_state_test_handler:marshal_aux_state(#{model => initialized}), Process = #{ process_id => <<"notify-test">>, @@ -746,7 +747,7 @@ lookup_unknown_namespace_returns_error() -> -spec process_unknown_namespace_returns_error() -> _. process_unknown_namespace_returns_error() -> - Opts = #{ns => unknown_ns, handling_timeout => 5000}, + Opts = #{ns => unknown_ns, handling_timeout => ?TEST_TIMEOUT}, Process = #{ process_id => <<"unknown-ns-test">>, last_event_id => 0, @@ -760,7 +761,7 @@ process_unknown_namespace_returns_error() -> -spec process_crash_conforms_progressor_exception() -> _. process_crash_conforms_progressor_exception() -> - Opts = #{ns => ?AUX_STATE_TEST_NS, handling_timeout => 5000}, + Opts = #{ns => ?AUX_STATE_TEST_NS, handling_timeout => ?TEST_TIMEOUT}, Process = #{ process_id => <<"crash-test">>, last_event_id => 0,