Skip to content

[Bug]: run tpcc test and then restore report Duplicate entry #16100

Closed

Description

@YANGGMM

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

newest

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

mysql> restore account sys from snapshot sp_01;
ERROR 1062 (HY000): Duplicate entry '1' for key 'hist_id'

mysql> restore account sys database tpcc from snapshot sp_01;
ERROR 1062 (HY000): Duplicate entry '8193' for key 'hist_id'

Expected Behavior

No response

Steps to Reproduce

1.create snapshot 

2.run tpcc test

3.restore

Additional information

No response

Activity

  1. added
    kind/bug
    on May 14, 2024
  2. added this to the 1.2.0 milestone on May 14, 2024
  3. added
    severity/s0
    on May 14, 2024
  4. YANGGMM commented on May 14, 2024

    @YANGGMM
    ContributorAuthor

    尝试复现

    mysql> show create table bmsql_history ;
    +---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table         | Create Table                                                                                                                                                                                                                                                                                                                                         |
    +---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | bmsql_history | CREATE TABLE `bmsql_history` (
    `hist_id` INT NOT NULL AUTO_INCREMENT,
    `h_c_id` INT DEFAULT NULL,
    `h_c_d_id` INT DEFAULT NULL,
    `h_c_w_id` INT DEFAULT NULL,
    `h_d_id` INT DEFAULT NULL,
    `h_w_id` INT DEFAULT NULL,
    `h_date` TIMESTAMP DEFAULT NULL,
    `h_amount` DECIMAL(6,2) DEFAULT NULL,
    `h_data` VARCHAR(24) DEFAULT NULL,
    PRIMARY KEY (`hist_id`)
    ) |
    +---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> create table `bmsql_history_restore`(`hist_id` INT NOT NULL AUTO_INCREMENT,`h_c_id` INT DEFAULT NULL,`h_c_d_id` INT DEFAULT NULL,`h_c_w_id` INT DEFAULT NULL,`h_d_id` INT DEFAULT NULL,`h_w_id` INT DEFAULT NULL,`h_date` TIMESTAMP DEFAULT NULL,`h_amount` DECIMAL(6,2) DEFAULT NULL,`h_data` VARCHAR(24) DEFAULT NULL,PRIMARY KEY (`hist_id`));
    Query OK, 0 rows affected (0.07 sec)
    
    mysql> insert into `bmsql_history_restore` select * from `bmsql_history` {snapshot = 'sp_01'};
    Query OK, 300000 rows affected (3.27 sec)
    

    恢复成功,而且数据量正确

  5. YANGGMM commented on May 14, 2024

    @YANGGMM
    ContributorAuthor

    用restore 报错

    mysql> restore account sys database tpcc table `bmsql_history` from snapshot sp_01;
    ERROR 1062 (HY000): Duplicate entry '8193' for key 'hist_id'
  6. YANGGMM commented on May 14, 2024

    @YANGGMM
    ContributorAuthor
    image
  7. YANGGMM commented on May 15, 2024

    @YANGGMM
    ContributorAuthor

    测试数据量最大的表restore,正常恢复

    mysql> restore account sys database tpcc table bmsql_order_line from snapshot sp_01;
    Query OK, 0 rows affected (12 min 57.49 sec)

    恢复后数据一切正常

    mysql> select count(*) from bmsql_order_line;
    +----------+
    | count(*) |
    +----------+
    |  2998810 |
    +----------+
    1 row in set (0.04 sec)
    
    mysql> select count(*) from bmsql_order_line{snapshot = 'sp_01'};
    +----------+
    | count(*) |
    +----------+
    |  2998810 |
    +----------+
    1 row in set (0.04 sec)
  8. YANGGMM commented on May 15, 2024

    @YANGGMM
    ContributorAuthor
    mysql>  restore account sys database tpcc table `bmsql_history` from snapshot sp_01;
    ERROR 1062 (HY000): Duplicate entry '16385' for key 'hist_id'
    mysql> 
    {"level":"ERROR","time":"2024/05/15 11:08:30.914112 +0800","caller":"fuzzyfilter/filter.go:275","msg":"error: Duplicate entry '16385' for key 'hist_id'","span":{"trace_id":"3df833af-1e84-c416-e634-d8f9cc4a1ed0","span_id":"d03e90d309a9ddaf"}}
    
  9. YANGGMM commented on May 15, 2024

    @YANGGMM
    ContributorAuthor
    cerate database tpcc;
    use tpcc;
    create table `bmsql_history` (`hist_id` INT NOT NULL AUTO_INCREMENT,`h_c_id` INT DEFAULT NULL,`h_c_d_id` INT DEFAULT NULL,`h_c_w_id` INT DEFAULT NULL,`h_d_id` INT DEFAULT NULL,`h_w_id` INT DEFAULT NULL,`h_date` TIMESTAMP DEFAULT NULL,`h_amount` DECIMAL(6,2) DEFAULT NULL,`h_data` VARCHAR(24) DEFAULT NULL,PRIMARY KEY (`hist_id`));
    
    
    

    --load file
    tpcccust-hist.csv

    create snapshot sp_01 for account sys;
    
     restore account sys database tpcc table `bmsql_history` from snapshot sp_01;
  10. jensenojs commented on May 15, 2024

    @jensenojs
    Contributor
    mysql>  restore account sys database tpcc table `bmsql_history` from snapshot sp_01;
    ERROR 1062 (HY000): Duplicate entry '16385' for key 'hist_id'
    mysql> 
    {"level":"ERROR","time":"2024/05/15 11:08:30.914112 +0800","caller":"fuzzyfilter/filter.go:275","msg":"error: Duplicate entry '16385' for key 'hist_id'","span":{"trace_id":"3df833af-1e84-c416-e634-d8f9cc4a1ed0","span_id":"d03e90d309a9ddaf"}}
    
    1. 和钊哥一起看了一下, fuzzy 的table scan不应该读取上来数据, 但读上来了.

    2. 在后台SQL的执行过程中用select count(*) from tblName试了一下, 没有读取上来数据

  11. Ariznawlll commented on May 15, 2024

    @Ariznawlll
    Collaborator

    情景一:
    单机测试了sysbench 点查
    commit:16a954e8eaa0c37f36c1fd6cc01691511758b69f
    数据量:10w
    测试步骤1:

    sys租户连接mo:
    create database sysbench_db;
    
    本地:git clone https://github.com/matrixorigin/mo-sysbench.git
    
    cd mo-sysbench
    sysbench  --mysql-host=127.0.0.1 --mysql-port=6001 --mysql-user=dump --mysql-password=111 oltp_point_select.lua --mysql-db=sysbench_db --tables=10 --table_size=100000 --threads=100 --time=30 --report-interval=10    cleanup
    
    建db并插入数据
    sysbench  --mysql-host=127.0.0.1 --mysql-port=6001 --mysql-user=dump --mysql-password=111 oltp_point_select.lua --mysql-db=sysbench_db --tables=10 --table_size=100000 --threads=100 --time=30 --report-interval=10    prepare
    
    sys租户连接mo:
    create snapshot sp01 for account sys;
    
    执行点查测试
    cd mo-sysbench
    sysbench  --mysql-host=127.0.0.1 --mysql-port=6001 --mysql-user=dump --mysql-password=111   oltp_point_select.lua --mysql-db=sysbench_db --tables=10 --table_size=100000 --threads=100 --time=300 --report-interval=10    --range_selects=off --point_selects=1 run
    
    sys租户连接mo:
    restore account sys from snapshot sp01;
    

    表schema:
    image

    restore结果:
    image

    测试步骤2:

    sys租户连接mo:
    create database sysbench_db;
    
    本地:git clone https://github.com/matrixorigin/mo-sysbench.git
    
    cd mo-sysbench
    sysbench  --mysql-host=127.0.0.1 --mysql-port=6001 --mysql-user=dump --mysql-password=111 oltp_point_select.lua --mysql-db=sysbench_db --tables=10 --table_size=100000 --threads=100 --time=30 --report-interval=10    cleanup
    
    建db并插入数据
    sysbench  --mysql-host=127.0.0.1 --mysql-port=6001 --mysql-user=dump --mysql-password=111 oltp_point_select.lua --mysql-db=sysbench_db --tables=10 --table_size=100000 --threads=100 --time=30 --report-interval=10    prepare
    
    sys租户连接mo:
    create snapshot sp01 for account sys;
    
    什么测试也不执行直接执行下面的restore
    
    sys租户连接mo:
    restore account sys from snapshot sp01;
    

    表schema:
    image

    image

    情景二:
    单机执行tpcc 10-1000测试:

    建表:https://github.com/matrixorigin/mo-tpcc/blob/main/sql/tableCreates.sql
    mysql -h 127.0.0.1 -P 6001 -udump -p111
    create snapshot sp03 for account sys;
    
    执行tpcc 10-1000测试
    restore account sys from snapshot sp03;
    
    image

    表schema:
    image

  12. 12 remaining items

  13. triump2020 commented on May 17, 2024

    @triump2020
    Contributor
    1. 基本上可以判定自增列有关系, 事务 的 insert into select xxx statement 执行 与 update mo_incremental_columns 并行执行, 每个statement 在 compile.Run 前会更新 txn.snapshotWriteOffset, 导致了reader 出现了万圣节问题.
    2. 这个问题 跟snaphsot read 无关,只是 snapshot read 更容易暴露问题.
  14. qingxinhome commented on May 22, 2024

    @qingxinhome
    Contributor

    Got it, deal with it as soon as possible

  15. qingxinhome commented on May 27, 2024

    @qingxinhome
    Contributor

    Positioning

  16. qingxinhome commented on May 29, 2024

    @qingxinhome
    Contributor

    问题原因详情已经
    FixRestoreDuplicateEntry#16100.zip

    确认,请参考文档

  17. qingxinhome commented on Jun 6, 2024

    @qingxinhome
    Contributor

    pr已提交,待合并

  18. qingxinhome commented on Jun 11, 2024

    @qingxinhome
    Contributor
  19. Ariznawlll commented on Jun 11, 2024

    @Ariznawlll
    Collaborator

    commit: 09c4d95

    情景1:

    sys租户连接mo:
    create database sysbench_db;
    
    本地:git clone https://github.com/matrixorigin/mo-sysbench.git
    
    cd mo-sysbench
    sysbench  --mysql-host=127.0.0.1 --mysql-port=6001 --mysql-user=dump --mysql-password=111 oltp_point_select.lua --mysql-db=sysbench_db --tables=10 --table_size=100000 --threads=100 --time=30 --report-interval=10    cleanup
    
    建db并插入数据
    sysbench  --mysql-host=127.0.0.1 --mysql-port=6001 --mysql-user=dump --mysql-password=111 oltp_point_select.lua --mysql-db=sysbench_db --tables=10 --table_size=100000 --threads=100 --time=30 --report-interval=10    prepare
    
    sys租户连接mo:
    create snapshot sp01 for account sys;
    
    执行点查测试
    cd mo-sysbench
    sysbench  --mysql-host=127.0.0.1 --mysql-port=6001 --mysql-user=dump --mysql-password=111   oltp_point_select.lua --mysql-db=sysbench_db --tables=10 --table_size=100000 --threads=100 --time=300 --report-interval=10    --range_selects=off --point_selects=1 run
    
    sys租户连接mo:
    restore account sys from snapshot sp01;
    
    image

    情景2:

    sys租户连接mo:
    create database sysbench_db;
    
    本地:git clone https://github.com/matrixorigin/mo-sysbench.git
    
    cd mo-sysbench
    sysbench  --mysql-host=127.0.0.1 --mysql-port=6001 --mysql-user=dump --mysql-password=111 oltp_point_select.lua --mysql-db=sysbench_db --tables=10 --table_size=100000 --threads=100 --time=30 --report-interval=10    cleanup
    
    建db并插入数据
    sysbench  --mysql-host=127.0.0.1 --mysql-port=6001 --mysql-user=dump --mysql-password=111 oltp_point_select.lua --mysql-db=sysbench_db --tables=10 --table_size=100000 --threads=100 --time=30 --report-interval=10    prepare
    
    sys租户连接mo:
    create snapshot sp01 for account sys;
    
    什么测试也不执行直接执行下面的restore
    
    sys租户连接mo:
    restore account sys from snapshot sp01;
    
    image

    情景3:
    create database tpcc;
    use tpcc;
    建表:https://github.com/matrixorigin/mo-tpcc/blob/main/sql/tableCreates.sql

    load 数据:

    创建快照:create snapshot sp01 for account sys;

    本地:git clone https://github.com/matrixorigin/mo-tpcc.git
    执行tpcc 10-100测试:./runBenchmark props.mo

    连接mo: mysql -h 127.0.0.1 -P 6001 -udump -p111

    restore account sys database tpcc from snapshot sp01;
    image

    测试通过.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugphase/testingresolved/v1.2.1severity/s0

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions