-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
TTL has unexpected timezone handling #52803
Comments
@lcwangchao @xhebox can you help to check if this is a bug or just something that we need to document on https://docs.pingcap.com/tidb/stable/time-to-live ? |
I think it's the same issue with #51675. The MySQL cannot handle time add for DST time zone correctly:
And we computes expire time by adding a interval to UNIX time 0: Lines 199 to 201 in e271864
We have fixed it in PR #51863 |
@lcwangchao I can no longer reproduce this on CREATE TABLE t1 (
id INT PRIMARY KEY,
created_at TIMESTAMP
) TTL=created_at + INTERVAL 1 MINUTE TTL_ENABLE='ON' TTL_JOB_INTERVAL='1m';
INSERT INTO t1 VALUES (1, CURRENT_TIMESTAMP);
INSERT INTO t1 VALUES (2, CURRENT_TIMESTAMP + INTERVAL 1 HOUR);
INSERT INTO t1 VALUES (3, CURRENT_TIMESTAMP + INTERVAL 2 HOUR);
INSERT INTO t1 VALUES (4, CURRENT_TIMESTAMP + INTERVAL 3 HOUR);
INSERT INTO t1 VALUES (5, CURRENT_TIMESTAMP - INTERVAL 1 HOUR);
INSERT INTO t1 VALUES (6, CURRENT_TIMESTAMP - INTERVAL 2 HOUR);
INSERT INTO t1 VALUES (7, CURRENT_TIMESTAMP - INTERVAL 3 HOUR);
SELECT
id,
created_at,
created_at + INTERVAL 1 MINUTE, CURRENT_TIMESTAMP,
created_at + INTERVAL 1 MINUTE > CURRENT_TIMESTAMP,
created_at + INTERVAL 2 MINUTE > CURRENT_TIMESTAMP
FROM
t1;
DO SLEEP(180);
SELECT
id,
created_at,
created_at + INTERVAL 1 MINUTE, CURRENT_TIMESTAMP,
created_at + INTERVAL 1 MINUTE > CURRENT_TIMESTAMP,
created_at + INTERVAL 2 MINUTE > CURRENT_TIMESTAMP
FROM
t1;
|
Bug Report
When creating a table with TTL set to
created_at + INTERVAL 1 MINUTE
I would expect rows to be expired after a minute.To make it easier to see what happens I have lowered the TTL_JOB_INTERVAL to one minute.
I have inserted rows with a
created_at
that are created:Observations:
created_at
that are one or more hours in the past are removed directlyttl_expire
column of themysql.tidb_ttl_job_history
table is one hour in the past.Note that
system_time_zone
is set toEurope/Amsterdam
, which is UTC+0200 (CEST).1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: