Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MINOR: Fix bug encountered when restoring RUN SCRIPT command. #2263

Merged
merged 2 commits into from
Dec 13, 2018

Conversation

vcrfxia
Copy link
Contributor

@vcrfxia vcrfxia commented Dec 12, 2018

Description

Currently, if you execute a RUN SCRIPT where the script contains a persistent query, then try to restart the KSQL server, the server will fail to restart. This happens because recent changes we introduced to the recovery logic result in the server attempting to start the persistent query created by the RUN SCRIPT twice, resulting in the following error:

[2018-12-12 19:59:46,205] ERROR Failed to start KSQL (io.confluent.ksql.rest.server.KsqlServerMain:47)
java.lang.IllegalStateException: Can only set StateListener in CREATED state. Current state is: REBALANCING
    at org.apache.kafka.streams.KafkaStreams.setStateListener(KafkaStreams.java:332)
    at java.util.Optional.ifPresent(Optional.java:159)
    at io.confluent.ksql.util.QueryMetadata.start(QueryMetadata.java:183)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080)
    at io.confluent.ksql.rest.server.computation.StatementExecutor.handleRestoration(StatementExecutor.java:104)
    at io.confluent.ksql.rest.server.computation.CommandRunner.processPriorCommands(CommandRunner.java:89)
    at io.confluent.ksql.rest.server.KsqlRestApplication.buildApplication(KsqlRestApplication.java:384)
    at io.confluent.ksql.rest.server.KsqlServerMain.createExecutable(KsqlServerMain.java:82)
    at io.confluent.ksql.rest.server.KsqlServerMain.main(KsqlServerMain.java:44)

The fix is simple: only start RUN SCRIPT queries once when recovering.

Testing done

Manual testing done. Added unit test.

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@vcrfxia vcrfxia requested a review from a team as a code owner December 12, 2018 22:36
Copy link
Contributor

@apurvam apurvam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for digging into this, and thanks for the patch!

Copy link
Contributor

@hjafarpour hjafarpour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants