Fix Pipeline stuck for INSERT SELECT FINAL

INSERT SELECT FINAL where SELECT (max_threads>1) has multiple streams
but INSERT has only one (max_insert_threads==0) will add ConcatProcessor
that will stuck the pipeline in this case.
This commit is contained in:
Azat Khuzhin 2020-06-05 01:11:48 +03:00
parent 5deda4c7fd
commit 1887e343ec
2 changed files with 21 additions and 4 deletions

View File

@ -4,6 +4,17 @@
namespace DB
{
ConcatProcessor::ConcatProcessor(const Block & header, size_t num_inputs)
: IProcessor(InputPorts(num_inputs, header), OutputPorts{header}), current_input(inputs.begin())
{
}
void ConcatProcessor::prepareInitializeInputs()
{
for (auto & input : inputs)
input.setNeeded();
}
ConcatProcessor::Status ConcatProcessor::prepare()
{
auto & output = outputs.front();
@ -42,6 +53,12 @@ ConcatProcessor::Status ConcatProcessor::prepare()
auto & input = *current_input;
if (!is_initialized)
{
prepareInitializeInputs();
is_initialized = true;
}
input.setNeeded();
if (!input.hasData())

View File

@ -16,10 +16,7 @@ namespace DB
class ConcatProcessor : public IProcessor
{
public:
ConcatProcessor(const Block & header, size_t num_inputs)
: IProcessor(InputPorts(num_inputs, header), OutputPorts{header}), current_input(inputs.begin())
{
}
ConcatProcessor(const Block & header, size_t num_inputs);
String getName() const override { return "Concat"; }
@ -29,6 +26,9 @@ public:
private:
InputPorts::iterator current_input;
bool is_initialized = false;
void prepareInitializeInputs();
};
}