You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@zookeeper.apache.org by "maoling (Jira)" <ji...@apache.org> on 2020/11/01 06:08:00 UTC

[jira] [Commented] (ZOOKEEPER-3986) ConcurrentModificationException in PrepRequestProcessor.checkACL

    [ https://issues.apache.org/jira/browse/ZOOKEEPER-3986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17224223#comment-17224223 ] 

maoling commented on ZOOKEEPER-3986:
------------------------------------

[~jhalterman]  I had reproduced this issue in the branch-3.5. Are you free to provide a patch against?

A code snippet:
{code:java}
public static void main(String[] args) {
    // only use one zk client to have the same ServerCnxn instance.
    final ZooKeeper zk = createClient();
    // make sure you have the path:/10-31-2 and use the CLI:
    // [zk: 127.0.0.1:2180(CONNECTED) 1] addauth digest user1:12345
    // [zk: 127.0.0.1:2180(CONNECTED) 2] getAcl /10-31-2
    //      'digest,'user1:+owfoSBn/am19roBPzR1/MfCblE=
    //      : cdrwa
    String path = "/10-31-2";

    try {
        //one thread
        new Thread(new Runnable() {
            @Override
            public void run() {
                zk.addAuthInfo("digest", "user1:12345".getBytes());
                Random r = new Random(1);
                for (int i = 0; i < 10000; i++) {
                    zk.addAuthInfo("digest", ("maoling" + r.nextInt(1000000) + "_" + System.currentTimeMillis() + ":12345").getBytes());
                }
                while (true) {
                    try {
                        System.out.println(zk.getChildren(path, null, new Stat()));
                        Thread.sleep(500);
                    } catch (KeeperException | InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();

        //anothor thread
        new Thread(new Runnable() {
            @Override
            public void run() {
                Random r = new Random(1);
                while (true) {
                    try {
                        String id = "gaki" + r.nextInt(10000000) + "_" + r.nextInt(10000) + "_" + System.currentTimeMillis() + ":12345";
                        zk.addAuthInfo("digest", id.getBytes());
                        Thread.sleep(500);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
{code}

> ConcurrentModificationException in PrepRequestProcessor.checkACL
> ----------------------------------------------------------------
>
>                 Key: ZOOKEEPER-3986
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3986
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: server
>    Affects Versions: 3.5.0
>            Reporter: Jonathan Halterman
>            Priority: Major
>
> We have some Zookeeper clusters under pretty heavy load that are occasionally throwing ConcurrentModificationException during ACL checking:
> {noformat}
>  
> ERROR [CommitProcWorkThread-17:FinalRequestProcessor@439] - Failed to process sessionid:0xa006cd06b181510 type:getChildren2 cxid:0x4dae zxid:0xfffffffffffffffe txntype:unknown reqpath:n/a
> java.util.ConcurrentModificationException
>  at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909)
>  at java.util.ArrayList$Itr.next(ArrayList.java:859)
>  at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1044)
>  at org.apache.zookeeper.server.PrepRequestProcessor.checkACL(PrepRequestProcessor.java:321)
>  at org.apache.zookeeper.server.FinalRequestProcessor.processRequest(FinalRequestProcessor.java:383)
>  at org.apache.zookeeper.server.quorum.CommitProcessor$CommitWorkRequest.doWork(CommitProcessor.java:297)
>  at org.apache.zookeeper.server.WorkerService$ScheduledWorkRequest.run(WorkerService.java:162)
>  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  at java.lang.Thread.run(Thread.java:748)
> {noformat}
> This appears to be caused by auths changing while we're processing a request, such as here:
> [https://github.com/apache/zookeeper/blob/branch-3.5/zookeeper-server/src/main/java/org/apache/zookeeper/server/ServerCnxn.java#L101-L110]
> The result of this appears to be that occasionally requests fail unexpectedly.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)