Alexey Serbin has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/22127


Change subject: [subprocess] KUDU-3624 Fix DoWait thread-safety
......................................................................

[subprocess] KUDU-3624 Fix DoWait thread-safety

waitpid() does return with an error if it is called with a pid that was
already shut down. So Subprocess::DoWait() stores the return value of
previous waitpid execution and returns it instead of running it again.
But in EchoSubprocessTest.TestSubprocessMetricsOnError it can happen
that SubprocessServer::ExitCheckerThread() and Subprocess::KillAndWait()
both call Subprocess::DoWait() and both of them call waitpid. And if
ExitCheckerThread() calls it second, then it fails the following check:
Check failed: _s.ok() Bad status: Runtime error: Unable
to wait on child: No child processes (error 10)

To fix this behaviour, wait_mutex_ is added. If a thread runs and
calls waitpid(), other threads won't execute it in the same time. If
locking is unsuccessful but the WaitMode is NON_BLOCKING, then return as
if nothing happened. Unit test SubprocessTest.TestMultiThreadWait
was added to verify executing two wait commands concurrently.

Change-Id: I1cb540860b439c26e1c8529123c8b29940d9f84f
Reviewed-on: http://gerrit.cloudera.org:8080/22056
Tested-by: Alexey Serbin <[email protected]>
Reviewed-by: Alexey Serbin <[email protected]>
(cherry picked from commit da6211df5f8df0c53ceedd542b61634f3bab7205)
---
M src/kudu/util/subprocess-test.cc
M src/kudu/util/subprocess.cc
M src/kudu/util/subprocess.h
3 files changed, 34 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/27/22127/1
--
To view, visit http://gerrit.cloudera.org:8080/22127
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: branch-1.18.x
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1cb540860b439c26e1c8529123c8b29940d9f84f
Gerrit-Change-Number: 22127
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Ádám Bakai <[email protected]>

Reply via email to