mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
dbms: fix thread-unsafety: retain mysqlxx::Pool::Entry for the whole duration of a query. [#METR-13298]
This commit is contained in:
parent
7f9e9da104
commit
3b3f5b17c4
@ -16,8 +16,12 @@ namespace DB
|
||||
class MySQLBlockInputStream final : public IProfilingBlockInputStream
|
||||
{
|
||||
public:
|
||||
MySQLBlockInputStream(mysqlxx::Query query, const Block & sample_block, const std::size_t max_block_size)
|
||||
: query{std::move(query)}, result{this->query.use()}, sample_block{sample_block}, max_block_size{max_block_size}
|
||||
MySQLBlockInputStream(const mysqlxx::PoolWithFailover::Entry & entry,
|
||||
const std::string & query_str,
|
||||
const Block & sample_block,
|
||||
const std::size_t max_block_size)
|
||||
: entry{entry}, query{this->entry->query(query_str)}, result{query.use()},
|
||||
sample_block{sample_block}, max_block_size{max_block_size}
|
||||
{
|
||||
types.reserve(sample_block.columns());
|
||||
|
||||
@ -105,6 +109,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
mysqlxx::PoolWithFailover::Entry entry;
|
||||
mysqlxx::Query query;
|
||||
mysqlxx::UseQueryResult result;
|
||||
Block sample_block;
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
BlockInputStreamPtr loadAll() override
|
||||
{
|
||||
last_modification = getLastModification();
|
||||
return new MySQLBlockInputStream{pool.Get()->query(load_all_query), sample_block, max_block_size};
|
||||
return new MySQLBlockInputStream{pool.Get(), load_all_query, sample_block, max_block_size};
|
||||
}
|
||||
|
||||
BlockInputStreamPtr loadIds(const std::vector<std::uint64_t> ids) override
|
||||
@ -44,7 +44,7 @@ public:
|
||||
last_modification = getLastModification();
|
||||
const auto query = composeLoadIdsQuery(ids);
|
||||
|
||||
return new MySQLBlockInputStream{pool.Get()->query(query), sample_block, max_block_size};
|
||||
return new MySQLBlockInputStream{pool.Get(), query, sample_block, max_block_size};
|
||||
}
|
||||
|
||||
bool isModified() const override { return getLastModification() > last_modification; }
|
||||
|
Loading…
Reference in New Issue
Block a user