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

fix bug that SharedQueryBlockInputStream may loss block randomly (#2759) #2761

Merged
23 changes: 8 additions & 15 deletions dbms/src/DataStreams/SharedQueryBlockInputStream.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#pragma once

#include <thread>

#include <Common/ConcurrentBoundedQueue.h>
#include <common/logger_useful.h>
#include <Common/typeid_cast.h>

#include <DataStreams/IProfilingBlockInputStream.h>

#include <thread>

namespace DB
{

Expand Down Expand Up @@ -37,15 +36,9 @@ class SharedQueryBlockInputStream : public IProfilingBlockInputStream
}
}

String getName() const override
{
return "SharedQuery";
}
String getName() const override { return "SharedQuery"; }

Block getHeader() const override
{
return children.back()->getHeader();
}
Block getHeader() const override { return children.back()->getHeader(); }

void readPrefix() override
{
Expand Down Expand Up @@ -100,7 +93,7 @@ class SharedQueryBlockInputStream : public IProfilingBlockInputStream
in->readPrefix();
while (!isCancelled())
{
Block block;
Block block = in->read();
do
{
if (isCancelled() || read_suffixed)
Expand All @@ -109,7 +102,7 @@ class SharedQueryBlockInputStream : public IProfilingBlockInputStream
queue.tryEmplace(0);
break;
}
} while (!queue.tryPush(block = in->read(), try_action_millisecionds));
} while (!queue.tryPush(block, try_action_millisecionds));

if (!block)
break;
Expand All @@ -131,11 +124,11 @@ class SharedQueryBlockInputStream : public IProfilingBlockInputStream
bool read_suffixed = false;

std::thread thread;
std::mutex mutex;
std::mutex mutex;

std::exception_ptr exception;

Logger * log;
BlockInputStreamPtr in;
};
}
} // namespace DB