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

If a TTL job is cancelled, the last_job_finish_time is incorrect. #58109

Closed
YangKeao opened this issue Dec 9, 2024 · 2 comments · Fixed by #58166
Closed

If a TTL job is cancelled, the last_job_finish_time is incorrect. #58109

YangKeao opened this issue Dec 9, 2024 · 2 comments · Fixed by #58166
Labels
affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@YangKeao
Copy link
Member

YangKeao commented Dec 9, 2024

The first assert intest.Assert(se.GetSessionVars().Location().String() == now.Location().String()) in job.finish is never true when job.finish is called from rescheduleJobs (but our tests didn't cover it yet). It's because in rescheduleJobs the now is in GlobalTimeZone (Asia/Shanghai in my case), and the se.GetSessionVars().Location().String() is always UTC.

It'll not be a big issue as the job is scheduled according to the start time, but the wrong finish time is still confusing for users.

@YangKeao
Copy link
Member Author

YangKeao commented Dec 9, 2024

I'll construct a case to reproduce it with real scenario (but not reading codes only).

@YangKeao
Copy link
Member Author

YangKeao commented Dec 9, 2024

I reproduced it:

mysql> select * from mysql.tidb_ttl_table_status;
+----------+-----------------+------------------+----------------------------------+---------------------+----------------------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------------+------------------------+---------------------------+------------------------+------------------------+-------------------+--------------------+--------------------------------+
| table_id | parent_table_id | table_statistics | last_job_id                      | last_job_start_time | last_job_finish_time | last_job_ttl_expire | last_job_summary                                                                                                                                                                                           | current_job_id | current_job_owner_id | current_job_owner_addr | current_job_owner_hb_time | current_job_start_time | current_job_ttl_expire | current_job_state | current_job_status | current_job_status_update_time |
+----------+-----------------+------------------+----------------------------------+---------------------+----------------------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------------+------------------------+---------------------------+------------------------+------------------------+-------------------+--------------------+--------------------------------+
|      118 |             118 | NULL             | 962a363d8240424b9f17f32ea021a039 | 2024-12-10 02:02:15 | 2024-12-10 10:04:07  | 2024-12-10 01:02:15 | {"total_rows":0,"success_rows":0,"error_rows":0,"total_scan_task":0,"scheduled_scan_task":0,"finished_scan_task":0,"scan_task_err":"TTL table has been removed or the TTL on this table has been stopped"} | NULL           | NULL                 | NULL                   | NULL                      | NULL                   | NULL                   | NULL              | NULL               | NULL                           |
+----------+-----------------+------------------+----------------------------------+---------------------+----------------------+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------------+------------------------+---------------------------+------------------------+------------------------+-------------------+--------------------+--------------------------------+
1 row in set (0.00 sec)

The correct last_job_finish_time should be very near to last_job_start_time, but it shifted more 8 hours.

@ti-chi-bot ti-chi-bot bot closed this as completed in 7ac73e9 Dec 11, 2024
@YangKeao YangKeao added the affects-8.5 This bug affects the 8.5.x(LTS) versions. label Jan 6, 2025
@YangKeao YangKeao added affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-8.5 This bug affects the 8.5.x(LTS) versions. severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant