From a288750cc8f873bee5290f008dedc167d16e66d9 Mon Sep 17 00:00:00 2001 From: maoling Date: Sun, 27 Oct 2019 17:34:11 +0800 Subject: [PATCH] ZOOKEEPER-3593:fix the default value of jute.maxbuffer in client side and an optimization for the documentation --- .../main/resources/markdown/zookeeperAdmin.md | 24 ++++++++++++------- .../markdown/zookeeperProgrammers.md | 7 +++--- .../zookeeper/client/ZKClientConfig.java | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md b/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md index b0f08fe9785..66da6ca98de 100644 --- a/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md +++ b/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md @@ -1384,15 +1384,23 @@ the variable does. set to no, ZooKeeper will not require updates to be synced to the media. -* *jute.maxbuffer:* : - (Java system property:**jute.maxbuffer**) - This option can only be set as a Java system property. +* *jute.maxbuffer* : + (Java system property:**jute.maxbuffer**). + - This option can only be set as a Java system property. There is no zookeeper prefix on it. It specifies the maximum - size of the data that can be stored in a znode. The default is - 0xfffff, or just under 1M. If this option is changed, the system - property must be set on all servers and clients otherwise - problems will arise. This is really a sanity check. ZooKeeper is - designed to store data on the order of kilobytes in size. + size of the data that can be stored in a znode. The unit is: byte. The default is + 0xfffff(1048575) bytes, or just under 1M. + - If this option is changed, the system property must be set on all servers and clients otherwise + problems will arise. + - When *jute.maxbuffer* in the client side is greater than the server side, the client wants to write the data + exceeds *jute.maxbuffer* in the server side, the server side will get **java.io.IOException: Len error** + - When *jute.maxbuffer* in the client side is less than the server side, the client wants to read the data + exceeds *jute.maxbuffer* in the client side, the client side will get **java.io.IOException: Unreasonable length** + or **Packet len is out of range!** + - This is really a sanity check. ZooKeeper is designed to store data on the order of kilobytes in size. + In the production environment, increasing this property to exceed the default value is not recommended for the following reasons: + - Large size znodes cause unwarranted latency spikes, worsen the throughput + - Large size znodes make the synchronization time between leader and followers unpredictable and non-convergent(sometimes timeout), cause the quorum unstable * *jute.maxbuffer.extrasize*: (Java system property: **zookeeper.jute.maxbuffer.extrasize**) diff --git a/zookeeper-docs/src/main/resources/markdown/zookeeperProgrammers.md b/zookeeper-docs/src/main/resources/markdown/zookeeperProgrammers.md index 26e4aa530bf..03e83c092f9 100644 --- a/zookeeper-docs/src/main/resources/markdown/zookeeperProgrammers.md +++ b/zookeeper-docs/src/main/resources/markdown/zookeeperProgrammers.md @@ -1305,10 +1305,11 @@ following reference and the password to unlock the file. * *jute.maxbuffer* : - It specifies the maximum size of the incoming data from the server. The default value is 4194304 - Bytes , or just 4 MB. This is really a sanity check. The ZooKeeper server is designed to store and send + In the client side, it specifies the maximum size of the incoming data from the server. The default is 0xfffff(1048575) bytes, + or just under 1M. This is really a sanity check. The ZooKeeper server is designed to store and send data on the order of kilobytes. If incoming data length is more than this value, an IOException - is raised. + is raised. This value of client side should keep same with the server side(Setting **System.setProperty("jute.maxbuffer", "xxxx")** in the client side will work), + otherwise problems will arise. * *zookeeper.kinit* : Specifies path to kinit binary. Default is "/usr/bin/kinit". diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/client/ZKClientConfig.java b/zookeeper-server/src/main/java/org/apache/zookeeper/client/ZKClientConfig.java index 3ba4c6af659..3012a35f983 100644 --- a/zookeeper-server/src/main/java/org/apache/zookeeper/client/ZKClientConfig.java +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/client/ZKClientConfig.java @@ -57,7 +57,7 @@ public class ZKClientConfig extends ZKConfig { */ @SuppressWarnings("deprecation") public static final String SECURE_CLIENT = ZooKeeper.SECURE_CLIENT; - public static final int CLIENT_MAX_PACKET_LENGTH_DEFAULT = 4096 * 1024; /* 4 MB */ + public static final int CLIENT_MAX_PACKET_LENGTH_DEFAULT = 0xfffff; /* 1 MB */ public static final String ZOOKEEPER_REQUEST_TIMEOUT = "zookeeper.request.timeout"; public static final String ZOOKEEPER_SERVER_PRINCIPAL = "zookeeper.server.principal"; /**