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

[FLINK-33358][sql] Fix Flink SQL Client fail to start in Flink on YARN #23629

Merged
merged 1 commit into from Feb 1, 2024

Conversation

PrabhuJoseph
Copy link
Contributor

What is the purpose of the change

Moves the flink sql client jar precedence before the Hadoop classpath to avoid conflicts with the older jline version from the Hadoop classpath.

Brief change log

  1. Changed the order of sql client jar and hadoop classpath in sql-client.sh

Verifying this change

Launched the Flink SQL Session and verified with Flink sql examples.

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no

@flinkbot
Copy link
Collaborator

flinkbot commented Oct 31, 2023

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@Samrat002
Copy link
Contributor

@flinkbot run azure

@PrabhuJoseph
Copy link
Contributor Author

@Samrat002 @1996fanrui Could you review this patch when you have time? Thanks.

Copy link
Contributor

@Samrat002 Samrat002 left a comment

Choose a reason for hiding this comment

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

Thank you Prabhu for the patch.
Changes looks good to me 🚀

Copy link
Member

@1996fanrui 1996fanrui left a comment

Choose a reason for hiding this comment

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

In my humble opinion, this change is fine. But I don't know much about the details of flink sql, and I'm not sure whether this change introduces additional risks. It would be better if there are flink sql experts to help and confirm.

Hi @lsyldliu , would you mind helping take a look this PR in your free time? thanks~

@lsyldliu
Copy link
Contributor

lsyldliu commented Nov 1, 2023

In my humble opinion, this change is fine. But I don't know much about the details of flink sql, and I'm not sure whether this change introduces additional risks. It would be better if there are flink sql experts to help and confirm.

Hi @lsyldliu , would you mind helping take a look this PR in your free time? thanks~

cc @fsk119

@PrabhuJoseph
Copy link
Contributor Author

@fsk119 Please review this patch when you have time. Thanks.

Copy link
Contributor

@ferenc-csaky ferenc-csaky left a comment

Choose a reason for hiding this comment

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

I think it makes sense for the SQL client JAR to take precedence over the Hadoop CP, so in general any deps that is shaded into the SQL client JAR will be picked up instead whatever is on the Hadoop CP.

Although these kind of errors are likely to depend on the environment, how the Hadoop CP is setup.

@PrabhuJoseph
Copy link
Contributor Author

@1996fanrui Could you help in committing this change. Thanks.

@rmoff
Copy link
Contributor

rmoff commented Jan 30, 2024

I am hitting the same problem, with Flink 1.18.1.

Setup

# Unpack clean 1.18.1 download
cd ~/flink
tar xf flink-1.18.1-bin-scala_2.12.tgz

# Unpack clean Hadoop download
cd ~/hadoop
tar xf hadoop-3.3.2.tar.gz

# Set `HADOOP_CLASSPATH` per instructions at 
# https://nightlies.apache.org/flink/flink-docs-release-1.18/docs/connectors/table/hive/overview/#dependencies
export HADOOP_CLASSPATH=`~/hadoop/hadoop-3.3.2/bin/hadoop classpath`

Check env

❯ echo $HADOOP_CLASSPATH
/Users/rmoff/hadoop/hadoop-3.3.2/etc/hadoop:/Users/rmoff/hadoop/hadoop-3.3.2/share/hadoop/common/lib/*:/Users/rmoff/hadoop/hadoop-3.3.2/share/hadoop/common/*:/Users/rmoff/hadoop/hadoop-3.3.2/share/hadoop/hdfs:/Users/rmoff/hadoop/hadoop-3.3.2/share/hadoop/hdfs/lib/*:/Users/rmoff/hadoop/hadoop-3.3.2/share/hadoop/hdfs/*:/Users/rmoff/hadoop/hadoop-3.3.2/share/hadoop/mapreduce/*:/Users/rmoff/hadoop/hadoop-3.3.2/share/hadoop/yarn:/Users/rmoff/hadoop/hadoop-3.3.2/share/hadoop/yarn/lib/*:/Users/rmoff/hadoop/hadoop-3.3.2/share/hadoop/yarn/*

Run SQL Client

❯ ./bin/sql-client.sh
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/rmoff/flink/flink-1.18.1/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/rmoff/hadoop/hadoop-3.3.2/share/hadoop/common/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

                                   ▒▓██▓██▒
                               ▓████▒▒█▓▒▓███▓▒
                            ▓███▓░░        ▒▒▒▓██▒  ▒
                          ░██▒   ▒▒▓▓█▓▓▒░      ▒████
                          ██▒         ░▒▓███▒    ▒█▒█▒
                            ░▓█            ███   ▓░▒██
                              ▓█       ▒▒▒▒▒▓██▓░▒░▓▓█
                            █░ █   ▒▒░       ███▓▓█ ▒█▒▒▒
                            ████░   ▒▓█▓      ██▒▒▒ ▓███▒
                         ░▒█▓▓██       ▓█▒    ▓█▒▓██▓ ░█░
                   ▓░▒▓████▒ ██         ▒█    █▓░▒█▒░▒█▒
                  ███▓░██▓  ▓█           █   █▓ ▒▓█▓▓█▒
                ░██▓  ░█░            █  █▒ ▒█████▓▒ ██▓░▒
               ███░ ░ █░          ▓ ░█ █████▒░░    ░█░▓  ▓░
              ██▓█ ▒▒▓▒          ▓███████▓░       ▒█▒ ▒▓ ▓██▓
           ▒██▓ ▓█ █▓█       ░▒█████▓▓▒░         ██▒▒  █ ▒  ▓█▒
           ▓█▓  ▓█ ██▓ ░▓▓▓▓▓▓▓▒              ▒██▓           ░█▒
           ▓█    █ ▓███▓▒░              ░▓▓▓███▓          ░▒░ ▓█
           ██▓    ██▒    ░▒▓▓███▓▓▓▓▓██████▓▒            ▓███  █
          ▓███▒ ███   ░▓▓▒░░   ░▓████▓░                  ░▒▓▒  █▓
          █▓▒▒▓▓██  ░▒▒░░░▒▒▒▒▓██▓░                            █▓
          ██ ▓░▒█   ▓▓▓▓▒░░  ▒█▓       ▒▓▓██▓    ▓▒          ▒▒▓
          ▓█▓ ▓▒█  █▓░  ░▒▓▓██▒            ░▓█▒   ▒▒▒░▒▒▓█████▒
           ██░ ▓█▒█▒  ▒▓▓▒  ▓█                █░      ░░░░   ░█▒
           ▓█   ▒█▓   ░     █░                ▒█              █▓
            █▓   ██         █░                 ▓▓        ▒█▓▓▓▒█░
             █▓ ░▓██░       ▓▒                  ▓█▓▒░░░▒▓█░    ▒█
              ██   ▓█▓░      ▒                    ░▒█▒██▒      ▓▓
               ▓█▒   ▒█▓▒░                         ▒▒ █▒█▓▒▒░░▒██
                ░██▒    ▒▓▓▒                     ▓██▓▒█▒ ░▓▓▓▓▒█▓
                  ░▓██▒                          ▓░  ▒█▓█  ░░▒▒▒
                      ▒▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░▓▓  ▓░▒█░

    ______ _ _       _       _____  ____  _         _____ _ _            _  BETA
   |  ____| (_)     | |     / ____|/ __ \| |       / ____| (_)          | |
   | |__  | |_ _ __ | | __ | (___ | |  | | |      | |    | |_  ___ _ __ | |_
   |  __| | | | '_ \| |/ /  \___ \| |  | | |      | |    | | |/ _ \ '_ \| __|
   | |    | | | | | |   <   ____) | |__| | |____  | |____| | |  __/ | | | |_
   |_|    |_|_|_| |_|_|\_\ |_____/ \___\_\______|  \_____|_|_|\___|_| |_|\__|

        Welcome! Enter 'HELP;' to list all available commands. 'QUIT;' to exit.

Command history file path: /Users/rmoff/.flink-sql-history



Exception in thread "main" org.apache.flink.table.client.SqlClientException: Could not read from command line.
        at org.apache.flink.table.client.cli.CliClient.getAndExecuteStatements(CliClient.java:221)
        at org.apache.flink.table.client.cli.CliClient.executeInteractive(CliClient.java:179)
        at org.apache.flink.table.client.cli.CliClient.executeInInteractiveMode(CliClient.java:121)
        at org.apache.flink.table.client.cli.CliClient.executeInInteractiveMode(CliClient.java:114)
        at org.apache.flink.table.client.SqlClient.openCli(SqlClient.java:169)
        at org.apache.flink.table.client.SqlClient.start(SqlClient.java:118)
        at org.apache.flink.table.client.SqlClient.startClient(SqlClient.java:228)
        at org.apache.flink.table.client.SqlClient.main(SqlClient.java:179)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.flink.table.client.config.SqlClientOptions
        at org.apache.flink.table.client.cli.parser.SqlClientSyntaxHighlighter.highlight(SqlClientSyntaxHighlighter.java:59)
        at org.jline.reader.impl.LineReaderImpl.getHighlightedBuffer(LineReaderImpl.java:3633)
        at org.jline.reader.impl.LineReaderImpl.getDisplayedBufferWithPrompts(LineReaderImpl.java:3615)
        at org.jline.reader.impl.LineReaderImpl.redisplay(LineReaderImpl.java:3554)
        at org.jline.reader.impl.LineReaderImpl.doCleanup(LineReaderImpl.java:2340)
        at org.jline.reader.impl.LineReaderImpl.cleanup(LineReaderImpl.java:2332)
        at org.jline.reader.impl.LineReaderImpl.readLine(LineReaderImpl.java:626)
        at org.apache.flink.table.client.cli.CliClient.getAndExecuteStatements(CliClient.java:194)
        ... 7 more

Shutting down the session...
done.

@rmoff
Copy link
Contributor

rmoff commented Jan 30, 2024

I can confirm that using the fix in this PR resolves the issue for me.

@PrabhuJoseph
Copy link
Contributor Author

Thanks @rmoff for the verification. @dannycranmer Could you please assist with reviewing this patch? Thank you.

Copy link
Member

@fsk119 fsk119 left a comment

Choose a reason for hiding this comment

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

LGTM

@fsk119 fsk119 merged commit fa364c7 into apache:master Feb 1, 2024
@PrabhuJoseph
Copy link
Contributor Author

Thanks @fsk119

@tchivs
Copy link

tchivs commented Apr 25, 2024

Sure enough it can be used

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