mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Fix data race of shell command
This commit is contained in:
parent
ec7b22d218
commit
bd9f526f93
@ -101,6 +101,12 @@ bool ShellCommand::tryWaitProcessWithTimeout(size_t timeout_in_seconds)
|
||||
out.close();
|
||||
err.close();
|
||||
|
||||
for (auto & [_, fd] : write_fds)
|
||||
fd.close();
|
||||
|
||||
for (auto & [_, fd] : read_fds)
|
||||
fd.close();
|
||||
|
||||
return waitForPid(pid, timeout_in_seconds);
|
||||
}
|
||||
|
||||
@ -287,6 +293,12 @@ int ShellCommand::tryWait()
|
||||
out.close();
|
||||
err.close();
|
||||
|
||||
for (auto & [_, fd] : write_fds)
|
||||
fd.close();
|
||||
|
||||
for (auto & [_, fd] : read_fds)
|
||||
fd.close();
|
||||
|
||||
LOG_TRACE(getLogger(), "Will wait for shell command pid {}", pid);
|
||||
|
||||
int status = 0;
|
||||
|
@ -439,11 +439,7 @@ namespace
|
||||
}
|
||||
|
||||
if (!executor->pull(chunk))
|
||||
{
|
||||
if (check_exit_code)
|
||||
command->wait();
|
||||
return {};
|
||||
}
|
||||
|
||||
current_read_rows += chunk.getNumRows();
|
||||
}
|
||||
@ -466,6 +462,9 @@ namespace
|
||||
if (thread.joinable())
|
||||
thread.join();
|
||||
|
||||
if (check_exit_code && !process_pool)
|
||||
command->wait();
|
||||
|
||||
rethrowExceptionDuringSendDataIfNeeded();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user