Parallel test runner deadlocks on concurrent runs

Open
#3,093 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp

Research direction

Start by locating the parallel test runner and reading its current Boost.Interprocess queue and named mutex handling; the issue does not name specific files or tests. Then trace how the parent and worker processes coordinate, and identify the existing runner tests or commands. Done means concurrent runs work, worker crashes and interrupted runs do not leave stuck state, and remaining tests are reported as aborted when workers fail.

Written by the indexing model from the issue text.

Description

The parallel test runner currently uses 3 global named Boost.Interprocess queues and a named mutex. This means that

  1. It's not possible to run more than one at a time, even from different checkouts.
  2. A crashed worker process deadlocks the run.
  3. An interrupted run (crash, Ctrl-C, killed in a debugger) leaves the global objects around.

Proposed solution: move all state management into the parent process and have worker processes talk to it via sockets on localhost:

  1. Parent listens on a random free port on localhost. It passes the port number to workers as a command-line argument. It also generates a random token and passes it to workers as an environment variable.
  2. Each worker connects with a handshake and the token. Parent ignores connections without the right token.
  3. Parent processes all requests from workers in one thread using Boost.Asio. All state is kept in the parent process and accessed from this thread. No locks and no global objects needed.

Pros:

  1. Supports any number of concurrent runs.
  2. No global system-wide objects. Crashed/interrupted runs don't leave orphaned global objects.
  3. Robust against crashes in workers. If a worker crashes, the test it was running is reported as aborted. The other workers carry on. If all workers die, the remaining tests are reported as aborted as well, and the run ends.
  4. Arguably simpler code with no locks. No dependency on Boost.Interprocess and librt.

Cons:

  1. Requires a loopback interface. This is present basically everywhere, even build sandboxes, but it is possible to make containers without it.
  2. We should probably bump the minimum Boost version for the parallel test runner to 1.69. It already does not really work with lower versions (see #2429), but there are even more asio related changes between 1.58 and 1.69.

@lballabio what do you think?

Dominant language
C++
Stars
7.7k
Forks
2.3k
Avg merge
4d 14h
Merged PRs (30d)
100

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lballabio/QuantLib

All issues in lballabio/QuantLib

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.