Skip to content

[fix] : fix restore related issues - #17773

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
jensenojs:restore-too-slow
Aug 9, 2024
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
jensenojs:restore-too-slow

Conversation

@jensenojs

@jensenojs jensenojs commented Jul 29, 2024 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #16099 #16638 #16138

What this PR does / why we need it:

由于backSession不计算stats, 所以导致restore的insert into select会被mo认为是tp类型的小型插入, 会导致

  1. 不走s3
  2. 没有开算子内的并行

对于snapshot读上来的数据, 直接返回HugeStats

@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label Jul 29, 2024
@mergify mergify Bot added the kind/bug Something isn't working label Jul 29, 2024
@jensenojs

Copy link
Copy Markdown
Contributor Author

性能对比结果

对于如下测试脚本, 在szpc上跑的结果

  • main : 前端插入耗时13s, restore耗时 1 min 30.2s
  • this pr : 前端插入耗时13s, restore耗时 12s

测试脚本

drop database if exists t;
create database t;
use t;
drop table if exists jensen;
create table jensen(a int primary key, b int);
insert into jensen select result, result from generate_series(1, 200000000) g;
drop snapshot if exists s0;
create snapshot s0 for account sys;
drop database t;
restore account sys database t table jensen from snapshot s0;

测试截图

upstream main :

image

this pr :

image

mo checkin regression

https://github.com/matrixorigin/ci-test/actions/runs/10140235666

@ouyuanning ouyuanning left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

跟倪涛再讨论下有没更好的方案吧

@jensenojs

Copy link
Copy Markdown
Contributor Author

考虑restore的时候直接把统计信息的值改成一个很大的值, 这样就不需要从头hack到尾了

@jensenojs

jensenojs commented Jul 29, 2024 •

Copy link
Copy Markdown
Contributor Author

修改之后 :

就是在reCal的时候, 如果读的是snapshot的数据的话, 返回 DefaultHugeStats, 顺便把之前的fix给revert了, 统一用这种方式去fix就好

commit d2f2be6edc3d4f7cde2696872d9cd7196f14de59
Author: Jensen <[email protected]>
Date:   Wed Jul 24 17:24:19 2024 +0800

    [fix] : for restore case, lock whole table to avoid lockservice panic (#17677)

    The data read from the snapshot is directly locked on the table, which can save more memory in most scenarios.

    Approved by: @YANGGMM, @badboynt1, @aunjgr, @ouyuanning
image

@jensenojs jensenojs changed the title [fix] : fix restore too slow [fix] : fix restore related issue Jul 30, 2024
@jensenojs jensenojs changed the title [fix] : fix restore related issue [fix] : fix restore related issues Jul 30, 2024
@jensenojs

Copy link
Copy Markdown
Contributor Author
image

把标识位放在QueryBuilder中, 测试结果如上, 辛苦倪涛哥再review一下吧

@mergify
mergify Bot merged commit 7341149 into matrixorigin:main Aug 9, 2024
@jensenojs
jensenojs deleted the restore-too-slow branch August 9, 2024 02:57
@jensenojs jensenojs mentioned this pull request Aug 9, 2024
1 task done
fengttt pushed a commit to fengttt/matrixone that referenced this pull request May 7, 2026
由于backSession不计算stats, 所以导致restore的`insert into select`会被`mo`认为是tp类型的小型插入, 会导致
1. 不走s3
2. 没有开算子内的并行

对于snapshot读上来的数据, 直接返回HugeStats

Approved by: @badboynt1, @ouyuanning, @aunjgr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants