zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kfirlevari <...@git.apache.org>
Subject [GitHub] zookeeper pull request #167: commitProcessor does not crash when an unseen c...
Date Sun, 12 Feb 2017 06:15:30 GMT
Github user kfirlevari commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/167#discussion_r100684222
  
    --- 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) {
    --- End diff --
    
    I think we can just add 1 read request prior to the update request (i.e., keep the test
as simple as possible and more readable). Also it'll be good to state the cxid of each new
request in the actual code, so that it'll be clear what is added and when (e.g., instead of
using "firstCXid", just write 0x100, 0x99, 0x98).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message