Why Is the RDS Database Time Read by a Flink Opensource SQL Job Different from RDS Database Time?
The time zone of a database is improperly set. Generally, there is a 13-hour difference.
Run the following statement in the RDS database:
show variables like '%time_zone%'
The execution result if as follows:
- time_zone indicates the database time zone. The value SYSTEM indicates the system time of the database server ('system_time_zone'). The value of the system time zone is CST. Therefore, the database time zone is CST.
- system_time_zone indicates the time zone of the server where the database is located. The server is a computer.
If the default time zone of the computer where the local database is located is China Standard Time, the value of system_time_zone is CST.
The real problem here is that time_zone is set to SYSTEM and system_time_zone is set to CST for an RDS for MySQL database. In the MySQL database, CST is China Standard Time (UTC+8), but it is Central Standard Time (USA) (UTC-5) in Java. Flink TaskManager is a Java process that reads the time zone set in the JDBC driver code of the MySQL database through TimeZone.getTimeZone(canonicalTimezone). The method gets time zone CST (UTC+8), but the actual time zone is CST (UTC-5).
Solution (either of the following method)
- Do not set the value of time_zone to SYSTEM. You can set it to, for example, +08:00.
- Add the time zone to jdbcUrl.
For example, jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai.
Flink SQL FAQs
- How Much Data Can Be Processed in a Day by a Flink SQL Job?
- Does Data in the Temporary Stream of Flink SQL Need to Be Cleared Periodically? How Do I Clear the Data?
- Why Is a Message Displayed Indicating That the OBS Bucket Is Not Authorized When I Select an OBS Bucket for a Flink SQL Job?
- How Do I Create an OBS Partitioned Table for a Flink SQL Job?
- How Do I Change the Number of Kafka Partitions of a Flink SQL Job Without Stopping It?
- How Do I Dump Data to OBS and Create an OBS Partitioned Table?
- Why Is Error Message "DLI.0005" Displayed When I Use an EL Expression to Create a Table in a Flink SQL Job?
- Why Is No Data Queried in the DLI Table Created Using the OBS File Path When Data Is Written to OBS by a Flink Job Output Stream?
- Why Does a Flink SQL Job Fails to Be Executed, and Is "connect to DIS failed java.lang.IllegalArgumentException: Access key cannot be null" Displayed in the Log?
- Why Is Error "Not authorized" Reported When a Flink SQL Job Reads DIS Data?
- Data Writing Fails After a Flink SQL Job Consumed Kafka and Sank Data to the Elasticsearch Cluster
- How Does Flink Opensource SQL Parse Nested JSON?
- Why Is the RDS Database Time Read by a Flink Opensource SQL Job Different from RDS Database Time?
- What Are the Syntax Differences Between Flink SQL and Flink Opensource SQL?
- Why Does Job Submission Fail When the failure-handler Parameter of the Elasticsearch Result Table for a Flink Opensource SQL Job Is Set to retry_rejected?
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.
more