Skip to content

Commit be011ae

Browse files
committed
Fix race condition when terminating supervisor after restoring default signals
We'd terminate the supervisor and let it consume the shutdown timeout, so it'd start the immediate shutdown, then do some assertions and terminate the supervisor again before it had the chance to finish, and as such, the TERM signal would arrive sometimes before and sometimes after default signal handlers would have been restored, resulting in an error (harmless, but annoying) as: ``` ..solid_queue/test/test_helper.rb:51: warning: Exception in finalizer #<Proc:0x00000001083ee550 (lambda)> ..solid_queue/test/test_helper.rb:51:in `fork': SIGTERM (SignalException) from ..solid_queue/test/test_helper.rb:51:in `run_supervisor_as_fork' from ..solid_queue/test/integration/processes_lifecycle_test.rb:9:in `block in <class:ProcessLifecycleTest>' ```
1 parent 896a270 commit be011ae

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/integration/processes_lifecycle_test.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ProcessLifecycleTest < ActiveSupport::TestCase
117117

118118
test "term supervisor exceeding timeout while there are jobs in-flight" do
119119
no_pause = enqueue_store_result_job("no pause")
120-
pause = enqueue_store_result_job("pause", pause: SolidQueue.shutdown_timeout + 1.second)
120+
pause = enqueue_store_result_job("pause", pause: SolidQueue.shutdown_timeout + 10.second)
121121

122122
signal_process(@pid, :TERM, wait: 0.1.second)
123123
wait_for_jobs_to_finish_for(SolidQueue.shutdown_timeout + 0.1.second)
@@ -132,6 +132,10 @@ class ProcessLifecycleTest < ActiveSupport::TestCase
132132

133133
# The process running the long job couldn't deregister, the other did
134134
assert_registered_workers_for(:background)
135+
136+
# Now wait until the supervisor finishes for real, which will complete the cleanup
137+
wait_for_process_termination_with_timeout(@pid, timeout: 1.second)
138+
assert_clean_termination
135139
end
136140

137141
test "process some jobs that raise errors" do

0 commit comments

Comments
 (0)