matrixorigin / matrixone

Hyperconverged cloud-edge native database
https://docs.matrixorigin.cn/en
Apache License 2.0
1.77k stars 275 forks source link

[Bug]: The result of count(*) is incorrect after restore. #16055

Closed Ariznawlll closed 5 months ago

Ariznawlll commented 5 months ago

Is there an existing issue for the same bug?

Branch Name

main

Commit ID

e46e42848939748d405c5089143835056f798b1c

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

image

Expected Behavior

No response

Steps to Reproduce

drop table if exists rs01;
create table rs01 (col1 int, col2 decimal(6), col3 varchar(30));
insert into rs01 values (1, null, 'database');
insert into rs01 values (2, 38291.32132, 'database');
insert into rs01 values (3, null, 'database management system');
insert into rs01 values (4, 10, null);
insert into rs01 values (1, -321.321, null);
insert into rs01 values (2, -1, null);
select count(*) from rs01;

drop snapshot if exists sp01;
create snapshot sp01 for account sys;
select count(*) from rs01 {snapshot = 'sp01'};
insert into rs01 values (2, -1, null);
insert into rs01 values (1, -321.321, null);
select * from rs01;

restore account sys from snapshot sp01;
select count(*) from rs01 {snapshot = 'sp01'}; -->出错的sql

Additional information

No response

YANGGMM commented 5 months ago
mysql> drop table if exists rs01;
Query OK, 0 rows affected (0.06 sec)

mysql> create table rs01 (col1 int, col2 decimal(6), col3 varchar(30));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into rs01 values (1, null, 'database');
Query OK, 1 row affected (0.01 sec)

mysql> insert into rs01 values (2, 38291.32132, 'database');
Query OK, 1 row affected (0.00 sec)

mysql> insert into rs01 values (3, null, 'database management system');
Query OK, 1 row affected (0.01 sec)

mysql> insert into rs01 values (4, 10, null);
Query OK, 1 row affected (0.00 sec)

mysql> insert into rs01 values (1, -321.321, null);
Query OK, 1 row affected (0.01 sec)

mysql> insert into rs01 values (2, -1, null);
Query OK, 1 row affected (0.00 sec)

mysql> select count(*) from rs01;
+----------+
| count(*) |
+----------+
|        6 |
+----------+
1 row in set (0.01 sec)

mysql> 
mysql> drop snapshot if exists sp01;
Query OK, 0 rows affected (0.02 sec)

mysql> create snapshot sp01 for account sys;
Query OK, 0 rows affected (0.01 sec)

mysql> select count(*) from rs01 {snapshot = 'sp01'};
+----------+
| count(*) |
+----------+
|        6 |
+----------+
1 row in set (0.01 sec)

mysql> select count(*) from rs01;
+----------+
| count(*) |
+----------+
|        8 |
+----------+
1 row in set (0.00 sec)

mysql> 
mysql> restore account sys from snapshot sp01;
Query OK, 0 rows affected (0.07 sec)

mysql> 
mysql> 
mysql> select count(*) from rs01 {snapshot = 'sp01'};
+----------+
| count(*) |
+----------+
|        8 |
+----------+
1 row in set (0.02 sec)

mysql> select * from rs01 {snapshot = 'sp01'};
+------+-------+----------------------------+
| col1 | col2  | col3                       |
+------+-------+----------------------------+
|    1 |  NULL | database                   |
|    2 | 38291 | database                   |
|    3 |  NULL | database management system |
|    4 |    10 | NULL                       |
|    1 |  -321 | NULL                       |
|    2 |    -1 | NULL                       |
+------+-------+----------------------------+
6 rows in set (0.03 sec)
YANGGMM commented 5 months ago
image
YANGGMM commented 5 months ago
image
YANGGMM commented 5 months ago

fixed

Ariznawlll commented 5 months ago

commit: 7922426e3effea12dbe900af0daf02a308d9f031

image

verified