Github user kfirlevari commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/167#discussion_r100684278
  
    --- Diff: 
src/java/test/org/apache/zookeeper/server/quorum/CommitProcessorConcurrencyTest.java
 ---
    @@ -374,4 +372,52 @@ public void noStarvationOfReadRequestsTest() throws 
Exception {
                         !processedRequests.contains(r));
             }
         }
    +
    +    /**
    +     * In the following test, we verify that we can handle the case that 
we got a commit 
    +     * of a request we never seen since the session that we just 
established. This can happen
    +     * when a session is just established and there is request waiting to 
be commited in the 
    +     * in the session queue but it sees a commit for a request in the 
previous connection
    +     */
    +    @Test(timeout = 1000)
    +    public void noCrashOnCommittedRequestsOfUnSeenRequestTest() throws 
Exception {
    +        final String path = 
"/noCrash/OnCommittedRequests/OfUnSeenRequestTest";
    +        final int iteration = 10;
    +        final int sessionid = 0x123456;
    +        final int firstCXid = 0x100;
    +        int readReqId = firstCXid;
    +        processor.stoppedMainLoop = true;
    +        HashSet<Request> localRequests = new HashSet<Request>();
    +        // queue the blocking commit
    +        Request firstCommittedReq = newRequest(
    +            new CreateRequest(path, new byte[0], Ids.OPEN_ACL_UNSAFE,
    +                CreateMode.PERSISTENT_SEQUENTIAL.toFlag()),
    +            OpCode.create, sessionid, readReqId++);
    +        processor.queuedRequests.add(firstCommittedReq);
    +        localRequests.add(firstCommittedReq);
    +        // queue read linkedRequest to queuedRequests
    +        for (; readReqId <= iteration+firstCXid; ++readReqId) {
    +            Request readReq = newRequest(new GetDataRequest(path, false),
    +                OpCode.getData, sessionid, readReqId);
    +            processor.queuedRequests.add(readReq);
    +            localRequests.add(readReq);
    +        }
    +        //run once
    +        
Assert.assertTrue(processor.queuedRequests.containsAll(localRequests));
    +        processor.initThreads(iteration* 2);
    +        processor.run();
    +        Assert.assertTrue(processedRequests.isEmpty());
    +        // now we get a commit originated from another host that handles 
this same session
    --- End diff --
    
    The story of the test so far wasn't clear to me until this point. Maybe add 
some comment stating that:
    1. We add an update followed by a read operation of the same session
    2. We verify that it the processor is waiting for the commit
    3. We add a commit that belongs to the same session but with smaller cxid, 
i.e., commit of an update from previous connection of this session.   
    4. We verify that the commit processor processed the old commit prior to 
the newer messages
    5. We verify that the commit processor handle all messages.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to