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

Slightly raised up the limit on max string and array size received from ZooKeeper #4398

Merged
merged 1 commit into from Feb 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions dbms/src/Common/ZooKeeper/ZooKeeperImpl.cpp
Expand Up @@ -14,6 +14,11 @@
#include <array>


/// ZooKeeper has 1 MB node size and serialization limit by default,
/// but it can be raised up, so we have a slightly larger limit on our side.
#define MAX_STRING_OR_ARRAY_SIZE (1 << 28) /// 256 MiB


namespace ProfileEvents
{
extern const Event ZooKeeperInit;
Expand Down Expand Up @@ -322,7 +327,6 @@ void read(bool & x, ReadBuffer & in)

void read(String & s, ReadBuffer & in)
{
static constexpr int32_t max_string_size = 1 << 20;
int32_t size = 0;
read(size, in);

Expand All @@ -336,7 +340,7 @@ void read(String & s, ReadBuffer & in)
if (size < 0)
throw Exception("Negative size while reading string from ZooKeeper", ZMARSHALLINGERROR);

if (size > max_string_size)
if (size > MAX_STRING_OR_ARRAY_SIZE)
throw Exception("Too large string size while reading from ZooKeeper", ZMARSHALLINGERROR);

s.resize(size);
Expand Down Expand Up @@ -369,12 +373,11 @@ void read(Stat & stat, ReadBuffer & in)

template <typename T> void read(std::vector<T> & arr, ReadBuffer & in)
{
static constexpr int32_t max_array_size = 1 << 20;
int32_t size = 0;
read(size, in);
if (size < 0)
throw Exception("Negative size while reading array from ZooKeeper", ZMARSHALLINGERROR);
if (size > max_array_size)
if (size > MAX_STRING_OR_ARRAY_SIZE)
throw Exception("Too large array size while reading from ZooKeeper", ZMARSHALLINGERROR);
arr.resize(size);
for (auto & elem : arr)
Expand Down