[
https://issues.apache.org/jira/browse/ZOOKEEPER-2977?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16391677#comment-16391677
]
ASF GitHub Bot commented on ZOOKEEPER-2977:
-------------------------------------------
Github user afine commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/474#discussion_r173243505
--- Diff: src/java/test/org/apache/zookeeper/server/ServerCnxnTest.java ---
@@ -0,0 +1,129 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.zookeeper.server;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.util.List;
+
+import org.apache.jute.Record;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.ZKTestCase;
+import org.apache.zookeeper.data.Id;
+import org.apache.zookeeper.proto.ReplyHeader;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ServerCnxnTest extends ZKTestCase {
+
+ /**
+ * Test getting a copy of authinfo to avoid parallel modification
impact
+ */
+ @Test
+ public void testServerCnxnGetAuthInfoWithCopy() throws Exception {
+ MockServerCnxn serverCnxn = new MockServerCnxn();
+ List<Id> authInfo = serverCnxn.getAuthInfo();
--- End diff --
nit: please fix this indentation
> Concurrency for addAuth corrupts quorum packets
> -----------------------------------------------
>
> Key: ZOOKEEPER-2977
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2977
> Project: ZooKeeper
> Issue Type: Bug
> Components: quorum
> Affects Versions: 3.4.9
> Environment: Affects all version in 3.4.x
> Reporter: sumit agrawal
> Assignee: sumit agrawal
> Priority: Critical
> Fix For: 3.4.12
>
> Attachments: 2977.patch
>
>
> When client performs multiple times addAuth with different credential at
> follower concurrently, the communication between follower gets corrupt. This
> causes shutdown of Follower due to the failure.
> Analysis:
> In org.apache.zookeeper.server.quorum.QuorumPacket.serialize method,
> * call a_.startVector(authinfo,"authinfo"); which write the length of
> authinfo to packet (suppose it writes length 1)
> * get length of authinfo to write all details in loop (here gets length as 2)
> <-- Here in concurrency scenario, buffer gets corrupt having extra bytes in
> channel for additional authinfo.
>
> So When Leader reads next quorum packet, it reads previous extra bytes
> (incorrect) and possibly identify greater size of message (as corrupt byte
> pattern) causes exception...
> Coordination > Unexpected exception causing shutdown while sock still open
> (LearnerHandler.java:633)
> java.io.IOException: Unreasonable length = 1885430131
>
>
> ServerCnxn.getAuthInfo returns Unmodifiable list, but while addAuthInfo,
> there is no check. So this causes concurrency issue.
>
>
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)