Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.1/server: Fix PMIx_Server_Finalize hang #1250

Merged
merged 1 commit into from
May 15, 2019

Conversation

karasevb
Copy link
Contributor

Corresponds to #1246

The hang was quite rare and appears as the result of the race condition
between PMIx progress thread and main thread calling
PMIx_Server_finalize.

The following sequence is possible:

| main thread   | Progress thread   |
|               | while(ev_active){ |
| ev_active=0   |                   |
| ev_break_loop |                   |
|               | ev_loop()         |

According to libevent manual, in this situation, libevent will
ignore ev_break_loop as it wasn't in the loop at the time
ev_break_loop() was called (see (b) in the libevent excerpt below)
So the progress thread will enter the loop and hang.

To fix this use event_base_loopexit that have desired behavior
(See section (a) of the excerpt below)

**excerpt from the libevent manual**:
```
...
Note also that event_base_loopexit(base,NULL) and event_base_loopbreak(base)
act differently when no event loop is running:

(a) loopexit schedules the next instance of the event loop to stop right
after the next round of callbacks are run (as if it had been invoked with
EVLOOP_ONCE)

(b) whereas loopbreak only stops a currently running loop, and has no
effect if the event loop isn’t running.
...
```

Signed-off-by: Artem Polyakov <artpol84@gmail.com>
(cherry picked from commit f652ae1)

Conflicts:
	src/runtime/pmix_progress_threads.c
@karasevb karasevb added the bug label May 14, 2019
@karasevb karasevb requested review from rhc54 and artpol84 May 14, 2019 06:06
@rhc54 rhc54 merged commit ea90fad into openpmix:v3.1 May 15, 2019
@karasevb karasevb deleted the 3.1/fix/srv_fini branch May 15, 2019 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants