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 count(*) of table snapshot read yesterday is different from that read today. #16272

Closed Ariznawlll closed 4 months ago

Ariznawlll commented 4 months ago

Is there an existing issue for the same bug?

Branch Name

main

Commit ID

68a9d5618cd84d56c32c1d4252a8d0ed7c11b195

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

今天查的:

image

Expected Behavior

昨天查的:

image

Steps to Reproduce

集群环境:
load tpcc 10warehouse data;
select count(*) from table;
create snapshot sp01 for account sys;
run tpcc 10-10 test;
select count(*) from table;
create snapshot sp02 for account sys;
run tpcc 10-10 test;
select count(*) from table;
create snapshot sp03 for account sys;

select count(*) from bmsql_new_order{snapshot = 'sp02'}; -->今天查的和昨天查的数据量不一样

Additional information

No response

YANGGMM commented 4 months ago
mysql> show create table bmsql_new_order;
+-----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table           | Create Table                                                                                                                                           |
+-----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+
| bmsql_new_order | CREATE TABLE `bmsql_new_order` (
`no_w_id` INT NOT NULL,
`no_d_id` INT NOT NULL,
`no_o_id` INT NOT NULL,
PRIMARY KEY (`no_w_id`,`no_d_id`,`no_o_id`)
)
YANGGMM commented 4 months ago
mysql> select count(*) from bmsql_new_order;
+----------+
| count(*) |
+----------+
|    90480 |
+----------+
1 row in set (0.01 sec)

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

run tpcc test

image
mysql> select count(*) from bmsql_new_order;
+----------+
| count(*) |
+----------+
|    91139 |
+----------+
1 row in set (0.01 sec)

mysql> select count(*) from bmsql_new_order{snapshot = 'sp_02'};
+----------+
| count(*) |
+----------+
|    90480 |
+----------+
1 row in set (0.06 sec)

run tpcc test

image
mysql> select count(*) from bmsql_new_order{snapshot = 'sp_02'};
+----------+
| count(*) |
+----------+
|    90480 |
+----------+
1 row in set (0.02 sec)

run tpcc test

image
mysql> select count(*) from bmsql_new_order{snapshot = 'sp_02'};
+----------+
| count(*) |
+----------+
|    90480 |
+----------+
1 row in set (0.03 sec)
YANGGMM commented 4 months ago
mysql> restore account sys database tpcc_10 table bmsql_new_order from snapshot sp_02;
Query OK, 0 rows affected (6 min 9.51 sec)

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

mysql> select count(*) from bmsql_new_order{snapshot = 'sp_02'};
+----------+
| count(*) |
+----------+
|    90480 |
+----------+
1 row in set (0.02 sec)
Ariznawlll commented 4 months ago

数据恢复到sp02,恢复后select count() from table的结果与select count() from table{snapshot = 'sp02'}的结果不一样:

image

log:https://grafana.ci.matrixorigin.cn/explore?panes=%7B%22a0v%22:%7B%22datasource%22:%22loki%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%7Bnamespace%3D%5C%22mo-big-data-20240520%5C%22%7D%20%7C%3D%20%60r-w%20conflict%60%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22loki%22%7D,%22editorMode%22:%22builder%22%7D%5D,%22range%22:%7B%22from%22:%22now-6h%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1

YANGGMM commented 4 months ago

fixed

Ariznawlll commented 4 months ago

testing

Ariznawlll commented 4 months ago

testing

Ariznawlll commented 4 months ago

由16620跟踪