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

show tables get wrong result after restart tidb and a snapshot read #55835

Closed
tiancaiamao opened this issue Sep 4, 2024 · 1 comment · Fixed by #55856
Closed

show tables get wrong result after restart tidb and a snapshot read #55835

tiancaiamao opened this issue Sep 4, 2024 · 1 comment · Fixed by #55856
Labels
feature/developing the related feature is in development severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@tiancaiamao
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. use infoschema v2
set @@global.tidb_schema_cache_size = '512MB';
  1. create table t and drop it, record the timestamp when t is available
use test;
create table t (id int);
select now();  ## get  '2024-09-04 09:48:54'
drop table t;
  1. restart tidb

  2. after a snapshot read, show tables goes wrong.

mysql> show tables;
Empty set (0.00 sec)

mysql> select * from t as of timestamp '2024-09-04 09:48:54';
Empty set (0.00 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t              |
+----------------+
1 row in set (0.00 sec)

2. What did you expect to see? (Required)

mysql> show tables;
Empty set (0.00 sec)

mysql> show full tables;
Empty set (0.00 sec)

mysql> select * from information_schema.tables where table_schema = 't';
Empty set (0.00 sec)

3. What did you see instead (Required)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t              |
+----------------+
1 row in set (0.00 sec)

mysql> show full tables;
Empty set (0.00 sec)

mysql> select * from information_schema.tables where table_schema = 't';
Empty set (0.00 sec)

4. What is your TiDB version? (Required)

master

@tiancaiamao tiancaiamao added type/bug The issue is confirmed as a bug. severity/moderate feature/developing the related feature is in development labels Sep 4, 2024
@tiancaiamao
Copy link
Contributor Author

This issue is similiar to #54926

After create and drop table, the infoschema history should be:

version 54:  t
version 55:  t = tomb

Then reading latest infoschema get the tomb and we know there are no tables.

When we restart tidb, we have no infoschema versions history.

no versions

After a snapshot read, the snapshot infoschema is inserted:

version 54: t

Now things go wrong, we do not have a tomb of version 55, so we mistakenly read the t.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/developing the related feature is in development 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.

2 participants