ANTLR Tool version 4.8 used for code generation does not match the current runtime version 4.7.1

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: ANTLR Tool version 4.8 used for code generation does not match the current runtime version 4.7.1

| username: OnTheRoad

【TiDB Usage Environment】Test Environment

  1. PD: 192.168.3.221/222/223:2379
  2. TiDB: 192.168.3.221/222/223:4000
  3. TiKV: 192.168.3.224/225/226
  4. Haproxy: 192.168.3.221:13390
  5. Spark: Master (192.168.3.227:7077), Worker (192.168.3.228/229)
  6. ${SPARK_HOME}/conf/spark-defaults.conf content as follows

    【TiDB Version】TiDB v5.4.2, Spark v3.1.3, TISpark tispark-assembly-3.1_2.12-3.0.1.jar

    【Encountered Issue】

【Reproduction Path】What operations were performed to cause the issue
Executing SQL statements in spark-sql prompts ANTLR version mismatch.
【Issue Phenomenon and Impact】


spark-sql> show database;
ANTLR Tool version 4.8 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.8 used for parser compilation does not match the current runtime version 4.7.122/07/27 22:53:34 WARN HttpClientUtil: Failed to send HTTP get request.

| username: ShawnYan | Original post link

spark.tispark.tidb.port 13390
What port is 13390?


I see, Haproxy: 192.168.3.221:13390

| username: OnTheRoad | Original post link

The load balancing port of Haproxy

| username: ShawnYan | Original post link

Are you using this package spark-3.1.3-bin-hadoop3.2?
Try switching to this one spark-3.1.3-bin-hadoop2.7.

| username: 爱白话的晓辉 | Original post link

We can display “show databases” but an error occurs related to Hive metadata when actually querying data.

| username: OnTheRoad | Original post link

  1. Changed to spark-3.1.3-bin-hadoop2.7 package, the issue persists.
  2. After replacing with tispark-assembly-3.1-2.5.1.jar, the ANTLR mismatch warning still exists, but the WARN HttpClientUtil: Failed to send HTTP get request warning disappeared, and SQL queries can be executed normally.
  3. Additionally, the spark-defaults.conf only retains the following configuration items:
    spark.sql.extensions org.apache.spark.sql.TiExtensions
    spark.tispark.pd.addresses 192.168.3.221:2379,192.168.3.222:2379,192.168.3.223:2379
    spark.tispark.write.allow_spark_sql true
    spark.master spark://192.168.3.227:7077

| username: 数据小黑 | Original post link

Can the issue be reproduced after the replacement? Is your TiDB deployed independently or on Kubernetes? Do you have a Spark 3.0.x environment? Could you please help test whether the error can be reproduced under Spark 3.0.x?

| username: 数据小黑 | Original post link

I looked through the source code of TiSpark and made a preliminary judgment that Spark 3.1.x references org.antlr:antlr4-runtime:4.8-1 during compilation, while tispark-assembly-3.1_2.12-3.0.1.jar most likely references org.antlr:antlr4-runtime:4.7 during its compilation, hence the warning. TiSpark uses tikv-client, and tikv-client uses org.antlr:antlr4-runtime:4.7, so I guess tispark-assembly-3.1_2.12-3.0.1.jar most likely references org.antlr:antlr4-runtime:4.7.

| username: 数据小黑 | Original post link

I’ve seen this error in several posts:


Between your two tests, the problematic one and the one without issues, did you make any changes to the PD address? Or was it newly copied?

| username: OnTheRoad | Original post link

I set up a Spark 3.1.3 cluster in my own test environment. If needed, I can try a Spark 3.0.x environment tomorrow during the day.

| username: OnTheRoad | Original post link

I deployed TiDB independently, and the OS is CentOS 7.9. After replacing tispark-assembly-3.1_2.12-3.0.1.jar with tispark-assembly-3.1-2.5.1.jar, the ANTLR warning still exists. However, the error “WARN HttpClientUtil: Failed to send HTTP get request.” has disappeared. SQL statements can also be executed normally.

| username: OnTheRoad | Original post link

I also noticed this error.
During the first test, the PD configuration in spark-defaults.conf was set to:
spark.tispark.pd.addresses 192.168.3.221:2379,192.168.3.222:2379,192.168.3.223:2379
After discovering this error, I thought it was a problem with my configuration, so I kept only one PD address:
spark.tispark.pd.addresses 192.168.3.221:2379
Then, the error seemed to disappear (I don’t remember clearly).
During the second test, I switched to spark-3.1.3-bin-hadoop2.7 and didn’t notice the PD error.
During the third test, after changing the TiSpark package to tispark-assembly-3.1-2.5.1.jar, I reverted the PD configuration to:
spark.tispark.pd.addresses 192.168.3.221:2379,192.168.3.222:2379,192.168.3.223:2379.
The error did not reappear.

| username: OnTheRoad | Original post link

After replacing Spark 3.1.3 with Spark 3.0.3, the warning about ANTLR version mismatch disappeared, and SQL queries can be executed normally.

| username: OnTheRoad | Original post link

The verified combinations that do not produce the ANTLR version does not match error are as follows:

  1. TiDB v5.4.2 - Spark v3.0.3 - TiSpark v2.5.1/v3.0.1

  2. TiDB v6.1 - Spark v3.0.3 - tispark-assembly-3.0_2.12-3.0.1.jar

spark-sql> use tidb_catalog.mysql;
22/07/29 03:38:08 WARN HttpClientUtil: Failed to send HTTP get request.
22/07/29 03:38:08 WARN TiSparkTeleInfo$: Failed to get PD version For input string: "2379,192.168.3.222:2379,192.168.3.223:2379"
22/07/29 03:38:08 WARN ObjectStore: Failed to get database global_temp, returning NoSuchObjectException
Time taken: 2.741 seconds
spark-sql> use tidb_catalog.mysql;
Time taken: 0.025 seconds
spark-sql> select * from user;
22/07/29 03:38:19 WARN package: Truncated the string representation of a plan since it was too large. This behavior can be adjusted by setting 'spark.sql.debug.maxToStringFields'.
%       root    *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B       mysql_native_password   Y       Y       Y       Y       Y       Y       Y       Y       Y       Y   YY       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       N       Y       Y       Y       Y   Y
%       admin   *4ACFE3202A5FF5CF467898FC58AAB1D615029441       mysql_native_password   Y       Y       Y       Y       Y       Y       Y       Y       Y       Y   YY       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       N       Y       Y       Y       Y   Y
Time taken: 2.552 seconds, Fetched 2 row(s)
  1. TiDB v6.1 - Spark v3.0.3 - tispark-assembly-3.0-2.5.1.jar
spark-sql> use tidb_catalog.mysql;
22/07/29 03:32:35 WARN ObjectStore: Failed to get database global_temp, returning NoSuchObjectException
Time taken: 2.641 seconds
spark-sql> use tidb_catalog.mysql;
Time taken: 0.024 seconds
spark-sql> select * from user;
22/07/29 03:32:42 WARN package: Truncated the string representation of a plan since it was too large. This behavior can be adjusted by setting 'spark.sql.debug.maxToStringFields'.
%       root    *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B       mysql_native_password   Y       Y       Y       Y       Y       Y       Y       Y       Y       Y   YY       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       N       Y       Y       Y       Y   Y
%       admin   *4ACFE3202A5FF5CF467898FC58AAB1D615029441       mysql_native_password   Y       Y       Y       Y       Y       Y       Y       Y       Y       Y   YY       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       Y       N       Y       Y       Y       Y   Y
Time taken: 2.78 seconds, Fetched 2 row(s)

The combinations that produce the ANTLR version does not match error are:

  1. TiDB v6.1 - Spark v3.1.3 - tispark-assembly-3.0-2.5.1.jar
ANTLR Tool version 4.8 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.8 used for parser compilation does not match the current runtime version 4.7.1ANTLR Tool version 4.8 used for code generation does not match the current runtime version 4.7.1ANTLR Runtime version 4.8 used for parser compilation does not match the current runtime version 4.7.1default
  1. TiDB v5.4.2 - Spark v3.1.3 - tispark-assembly-3.0-2.5.1.jar

  2. TiDB v5.4.2 - Spark v3.1.3 - tispark-assembly-3.1_2.12-3.0.1.jar

Based on the above results, it is preliminarily determined that ANTLR 4.8 is introduced in Spark v3.1.3, while ANTLR 4.7 is introduced in Spark v3.0.3, and the ANTLR version introduced in TiDB 5.x/6.x and TiSpark 2.5.x/3.x is 4.7.1.

| username: wfxxh | Original post link

Environment:
TiDB: v5.4.2
TiSpark: 3.1_2.12-3.0.1
Spark: 3.1.3
I did not reproduce your issue. There is indeed a problem with the PD address resolution.

| username: 数据小黑 | Original post link

I tried changing the half-width colon to a full-width colon, and the error message is as follows:

22/07/29 07:51:42 WARN PDClient: failed to get member from pd server.

2022/7/29 15:51:42 com.pingcap.tikv.exception.TiKVException: Failed to build NettyChannelBuilder
Error with an added space:
java.lang.IllegalArgumentException: Illegal character in authority at index 7: http://basic-pd.tidb-cluster: 2379
It seems that the issue is not caused by half-width/full-width or space:
22/07/27 23:15:56 WARN TiSparkTeleInfo$: Failed to get PD version For input string: “2379,192.168.3.222:23379,192.168.3.223:2379”

| username: 数据小黑 | Original post link

Are you saying that even with the error “Failed to get PD version For input string: ‘2379,192.168.3.222:23379,192.168.3.223:2379’”, it is still accessible?

| username: 数据小黑 | Original post link

I looked through previous Q&A, and this post also has the same error, but it shouldn’t be the reason in the end.

| username: wfxxh | Original post link

There is an issue with the URL used to get the PD status, which causes an exception to be thrown. However, this does not affect the overall operation, and the value will be set to UNKNOWN. This is a bug.

| username: Vain | Original post link

This issue has been fixed.