Skip to content

Always shutdown webrick even if thread is not alive

Lin Jen-Shin requested to merge always-shutdown-webrick into master

What does this MR do and why?

Always shutdown webrick even if thread is not alive

This should properly shutdown webrick so that we don't need to forcefully kill the thread to shutdown webrick in the tests.

Without properly shutting down webrick, we leak threads and other resources to each test cases, eventually causing everything to slow down and timing out the CI jobs.

This is discovered in #462928 (comment 1916591506)

A quick fix was proposed in the above thread and merged in !153887 (merged)

This should properly shutdown webrick instead.

  • It should be safe to shutdown webrick regardless
  • In a test, we use a thread to wrap around WEBrick::HTTPServer, turning the blocking server into a non-blocking server. This means the daemon thread will stop immediately because everything is wrapped inside another thread. If we only shutdown webrick when the thread is alive, we're not shutting it down in this test case either, leaking resources.

This preserves similar performance comparing to killing the thread.

This partially reverts f5b1317a

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by Lin Jen-Shin

Merge request reports