You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "huxihx (JIRA)" <ji...@apache.org> on 2018/04/02 01:26:00 UTC

[jira] [Updated] (KAFKA-6731) waitOnState waits for the wrong state instead of the target one

     [ https://issues.apache.org/jira/browse/KAFKA-6731?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

huxihx updated KAFKA-6731:
--------------------------
    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?
{code:java}
// ......
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;
{code}
IMO, it should check the state to be the target one. 

[~guozhang] Does is make sense?

  was:
In KafkaStreams.waitOnState, the code will waits the state to be set to NOT_RUNNING instead of the given target state. Is it deliberately as designed?
{code:java}
// ......
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;
{code}
IMO, it should check the state to be the target one. 

[~guozhang] Does is make sense?


> waitOnState waits for the wrong state instead of the target one
> ---------------------------------------------------------------
>
>                 Key: KAFKA-6731
>                 URL: https://issues.apache.org/jira/browse/KAFKA-6731
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>            Reporter: huxihx
>            Assignee: huxihx
>            Priority: Major
>
> 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?
> {code:java}
> // ......
> 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;
> {code}
> IMO, it should check the state to be the target one. 
> [~guozhang] Does is make sense?



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)