Bug 242083

Summary: [run-benchmark] Avoid race condition when killing the browser subprocess on Linux
Product: WebKit Reporter: Carlos Alberto Lopez Perez <clopez>
Component: Tools / TestsAssignee: Carlos Alberto Lopez Perez <clopez>
Status: RESOLVED FIXED    
Severity: Normal CC: dewei_zhu, jbedard, saam, simon.fraser, slewis, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Carlos Alberto Lopez Perez 2022-06-28 14:30:12 PDT
When the run-benchmark runner for Linux attempts to kill the browser first it kills the main browser process and then it kills all the browser subprocess if those are still alive.

The issue is that there is a race condition between the check of the subprocess being alive and the kill call, sometimes the the child ends in the interval between the is_running() and kill() call causing an exception on the runner.

This can be seen here https://build.webkit.org/#/builders/26/builds/2163/steps/13/logs/stdio

2022-06-28 08:58:10,070 - INFO - Cleaning Benchmark
2022-06-28 08:58:10,098 - ERROR - Error running benchmark plan: jetstream2
Traceback (most recent call last):
  File "/home/buildbot/worker/GTK-Linux-64-bit-Release-Perf/build/Tools/Scripts/webkitpy/browserperfdash/browserperfdash_runner.py", line 163, in run
    runner.execute()
  File "/home/buildbot/worker/GTK-Linux-64-bit-Release-Perf/build/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py", line 120, in execute
    self._run_benchmark(int(self._plan['count']), web_root)
  File "/home/buildbot/worker/GTK-Linux-64-bit-Release-Perf/build/Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py", line 90, in _run_benchmark
    result = self._run_one_test(web_root, self._plan['entry_point'])
  File "/home/buildbot/worker/GTK-Linux-64-bit-Release-Perf/build/Tools/Scripts/webkitpy/benchmark_runner/webserver_benchmark_runner.py", line 61, in _run_one_test
    self._browser_driver.close_browsers()
  File "/home/buildbot/worker/GTK-Linux-64-bit-Release-Perf/build/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py", line 85, in close_browsers
    browser_child.kill()
  File "/usr/lib/python3/dist-packages/psutil/__init__.py", line 383, in wrapper
    raise NoSuchProcess(self.pid, self._name)
psutil.NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=9447)
Comment 1 Carlos Alberto Lopez Perez 2022-06-28 15:32:41 PDT
Pull request: https://github.com/WebKit/WebKit/pull/1874
Comment 2 EWS 2022-06-28 17:31:08 PDT
Committed 251936@main (7fd0981bb9da): <https://commits.webkit.org/251936@main>

Reviewed commits have been landed. Closing PR #1874 and removing active labels.
Comment 3 Radar WebKit Bug Importer 2022-06-28 17:32:17 PDT
<rdar://problem/96102475>