mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +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();
|
out.close();
|
||||||
err.close();
|
err.close();
|
||||||
|
|
||||||
|
for (auto & [_, fd] : write_fds)
|
||||||
|
fd.close();
|
||||||
|
|
||||||
|
for (auto & [_, fd] : read_fds)
|
||||||
|
fd.close();
|
||||||
|
|
||||||
return waitForPid(pid, timeout_in_seconds);
|
return waitForPid(pid, timeout_in_seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,6 +293,12 @@ int ShellCommand::tryWait()
|
|||||||
out.close();
|
out.close();
|
||||||
err.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);
|
LOG_TRACE(getLogger(), "Will wait for shell command pid {}", pid);
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
@ -439,11 +439,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!executor->pull(chunk))
|
if (!executor->pull(chunk))
|
||||||
{
|
|
||||||
if (check_exit_code)
|
|
||||||
command->wait();
|
|
||||||
return {};
|
return {};
|
||||||
}
|
|
||||||
|
|
||||||
current_read_rows += chunk.getNumRows();
|
current_read_rows += chunk.getNumRows();
|
||||||
}
|
}
|
||||||
@ -466,6 +462,9 @@ namespace
|
|||||||
if (thread.joinable())
|
if (thread.joinable())
|
||||||
thread.join();
|
thread.join();
|
||||||
|
|
||||||
|
if (check_exit_code && !process_pool)
|
||||||
|
command->wait();
|
||||||
|
|
||||||
rethrowExceptionDuringSendDataIfNeeded();
|
rethrowExceptionDuringSendDataIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user