Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-10630

Possible race condition in RetryInvocationHandler

VotersStop watchingWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.5.0
    • None
    • None
    • Reviewed

    Description

      In one of our system tests with NameNode HA setup, we ran 300 threads in LoadGenerator. While one of the NameNodes was already in the active state and started to serve, we still saw one of the client thread failed all the retries in a 20 seconds window. In the meanwhile, we saw a lot of following warning msg in the log:

      WARN retry.RetryInvocationHandler: A failover has occurred since the start of this method invocation attempt.
      

      After checking the code, we see the following code in RetryInvocationHandler:

        while (true) {
            // The number of times this invocation handler has ever been failed over,
            // before this method invocation attempt. Used to prevent concurrent
            // failed method invocations from triggering multiple failover attempts.
            long invocationAttemptFailoverCount;
            synchronized (proxyProvider) {
              invocationAttemptFailoverCount = proxyProviderFailoverCount;
            }
            ......
            if (action.action == RetryAction.RetryDecision.FAILOVER_AND_RETRY) {
                  // Make sure that concurrent failed method invocations only cause a
                  // single actual fail over.
                  synchronized (proxyProvider) {
                    if (invocationAttemptFailoverCount == proxyProviderFailoverCount) {
                      proxyProvider.performFailover(currentProxy.proxy);
                      proxyProviderFailoverCount++;
                      currentProxy = proxyProvider.getProxy();
                    } else {
                      LOG.warn("A failover has occurred since the start of this method"
                          + " invocation attempt.");
                    }
                  }
                  invocationFailoverCount++;
                }
           ......
      

      We can see we refresh the value of currentProxy only when the thread performs the failover (while holding the monitor of the proxyProvider). Because "currentProxy" is not volatile, a thread that does not perform the failover (in which case it will log the warning msg) may fail to get the new value of currentProxy.

      Attachments

        1. HADOOP-10630.000.patch
          1 kB
          Jing Zhao

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jingzhao Jing Zhao
            jingzhao Jing Zhao
            Votes:
            1 Vote for this issue
            Watchers:
            7 Stop watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Issue deployment