Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-6731

waitOnState waits for the wrong state instead of the target one

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0
    • Component/s: streams
    • Labels:
      None

      Description

      In KafkaStreams.waitOnState, the code waits the state to be set to NOT_RUNNING instead of the given target state. Is it deliberately as designed?

      // ......
      while (state != State.NOT_RUNNING) {
          if (waitMs == 0) {
              try {
                  stateLock.wait();
              } catch (final InterruptedException e) {
                  // it is ok: just move on to the next iteration
              }
          } else if (waitMs > elapsedMs) {
              long remainingMs = waitMs - elapsedMs;
              try {
                  stateLock.wait(remainingMs);
              } catch (final InterruptedException e) {
                  // it is ok: just move on to the next iteration
              }
          } else {
              log.debug("Cannot transit to {} within {}ms", targetState, waitMs);
              return false;
          }
          elapsedMs = time.milliseconds() - begin;
      }
      return true;
      

      IMO, it should check the state to be the target one. 

      Guozhang Wang Does is make sense?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                huxi_2b huxihx
                Reporter:
                huxi_2b huxihx
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: