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

fix stonedb for optimize exists subquery and deep memory copy #369 (#330, #329, #340, #332) #369

Merged
merged 6 commits into from
Aug 9, 2022

Conversation

adofsauron
Copy link
Collaborator

@adofsauron adofsauron commented Aug 5, 2022

Summary about this PR

mtr测试结果:

[100%] shutdown_report                          [ pass ]       
--------------------------------------------------------------------------
The servers were restarted 22 times
Spent 4.815 of 218 seconds executing testcases

Check of testcase failed for: tianmu.group_concat2 tianmu.issue475 tianmu.issue469 tianmu.issue405 tianmu.truncate tianmu.issue502 tianmu.issue429 tianmu.concat tianmu.issue468 tianmu.casewhen tianmu.insert tianmu.lz4 tianmu.add_column tianmu.group_concat tianmu.orquery tianmu.issue430 tianmu.orquery1 tianmu.issue431 tianmu.issue464 tianmu.issue496 tianmu.issue467 tianmu.drop_column tianmu.issue417

Completed: All 24 tests were successful.

exists子句测试结果

2825D0DA-B2BC-4152-BAD6-BB8E092837D2

subquery-Exists-paral-20220804Aug081659590831 mysql

/stonedb57/install/bin/mysql -D tpch -e 'select
                            o_orderpriority,
                            count(*) as order_count
                        from
                            orders
                        where
                            o_orderdate >= date '\''1993-07-01'\''
                            and o_orderdate < date '\''1993-07-01'\'' + interval '\''3'\'' month
                            and exists (
                                select
                                    *
                                from
                                    lineitem
                                where
                                    l_orderkey = o_orderkey
                                    and l_commitdate < l_receiptdate
                            )
                        group by
                            o_orderpriority
                        order by
                            o_orderpriority ;'
Warning:
PID/TID switch overriding SYSTEM
o_orderpriority	order_count
1-URGENT	114839
2-HIGH	114276
3-MEDIUM	114716
4-NOT SPECIFIED	114913
5-LOW	114927

Q2子句测试

lQLPJxaQ2RwQ9jHNAb7NAb-w8aXzqpOpS80C7mKqXsBUAA_447_446

slow-q2-hash-paral-20220805Aug081659700965 mysql

Issue Number: close #330 #329

Tests Check List

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Changelog

  • New Feature
  • Bug Fix
  • Improvement
  • Performance Improvement
  • Build/Testing/CI/CD
  • Documentation
  • Not for changelog (changelog entry is not required)

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features

@mergify
Copy link
Contributor

mergify bot commented Aug 5, 2022

This pull request's title should follow requirements next. @adofsauron please check it 👇.

Valid format:

fix(vc): fix sth..... (#3306)
  ^         ^---------^  ^----^
  |         |            |
  |         +            +-> you issue id.
  |         |
  |         +-> Summary in present tense.
  |
  +-------> Type: feat, fix, docs, workflow, style, refactor, test, website, chore

Valid types:

  • feat: new feature for stonedb
  • fix: bug fix for stonedb
  • docs: changes to the documentation
  • workflow: ci/cd in .github
  • refactor: refactoring production code, eg. renaming a variable
  • style: formatting, missing semi colons, etc; no production code change
  • test: adding missing tests, refactoring tests; no production code change
  • website
  • chore: updating grunt tasks etc; no production code change

@mergify
Copy link
Contributor

mergify bot commented Aug 5, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@adofsauron adofsauron changed the title fix stonedb for optimize exists subquery and deep memcopy copy fix stonedb for optimize exists subquery and deep memcopy copy #369 (#330) Aug 5, 2022
@adofsauron adofsauron changed the title fix stonedb for optimize exists subquery and deep memcopy copy #369 (#330) fix stonedb for optimize exists subquery and deep memory copy #369 (#330) Aug 5, 2022
fix ParameterizedFilter deep copy mind memory leak
@adofsauron adofsauron changed the title fix stonedb for optimize exists subquery and deep memory copy #369 (#330) fix stonedb for optimize exists subquery and deep memory copy #369 (#330, #329) Aug 6, 2022
Copy link
Collaborator

@isredstar isredstar left a comment

Choose a reason for hiding this comment

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

LGTM

storage/tianmu/core/joiner.cpp Outdated Show resolved Hide resolved
storage/tianmu/core/joiner.cpp Outdated Show resolved Hide resolved
storage/tianmu/core/joiner.cpp Outdated Show resolved Hide resolved
storage/tianmu/core/temp_table.h Outdated Show resolved Hide resolved
storage/tianmu/core/temp_table.h Outdated Show resolved Hide resolved
@adofsauron
Copy link
Collaborator Author

adofsauron commented Aug 8, 2022

摘要:
记录在并行hash join时候去除DimensionGroupMultiMaterialized的深拷贝

核心函数:

DimensionGroupMultiMaterialized::Clone

DimensionGroup *DimensionGroupMultiMaterialized::Clone(bool shallow) {
  DimensionGroupMultiMaterialized *new_value = new DimensionGroupMultiMaterialized(no_obj, dims_used_, power_);
  if (shallow) return new_value;
  for (int index = 0; index < dims_count_; ++index) {
    MultiIndexTable *tables = dim_tables_[index];
    if (tables) {
      tables->Lock();
      new_value->dim_tables_[index] = new MultiIndexTable(*tables);
      tables->Unlock();
    }
  }
  return new_value;
}

优化后:

DimensionGroupMultiMaterialized::Clone

DimensionGroup *DimensionGroupMultiMaterialized::Clone(bool shallow) {
  DimensionGroupMultiMaterialized *new_value = new DimensionGroupMultiMaterialized(no_obj, dims_used_, power_, shallow);
  for (int index = 0; index < dims_count_; ++index) {
    MultiIndexTable *tables = dim_tables_[index];
    if (tables) {
      tables->Lock();
      if (shallow) {
        new_value->dim_tables_[index] = tables;
      } else {
        new_value->dim_tables_[index] = new MultiIndexTable(*tables);
      }

      tables->Unlock();
    }
  }
  return new_value;
}

DimensionGroupMultiMaterialized的析构函数

DimensionGroupMultiMaterialized::~DimensionGroupMultiMaterialized() {
  if (is_shallow_memory) {
    return;
  }

  for (auto it : dim_tables_) delete it;
}

执行测试:

dbc92944a28b2ab150a330fe558351a

slow-q18-hash-paral-20220807Aug081659863386 mysql

结论:

  1. 执行结果无异常
  2. 执行耗时Q18, 由6min削减为4min30s
  3. 内存稳定保持在60GB (执行前后都是)

@adofsauron adofsauron changed the title fix stonedb for optimize exists subquery and deep memory copy #369 (#330, #329) fix stonedb for optimize exists subquery and deep memory copy #369 (#330, #329, #340) Aug 8, 2022
@andyli029
Copy link
Contributor

Fix the commit log.

@andyli029 andyli029 self-requested a review August 8, 2022 12:20
@adofsauron adofsauron changed the title fix stonedb for optimize exists subquery and deep memory copy #369 (#330, #329, #340) fix stonedb for optimize exists subquery and deep memory copy #369 (#330, #329, #340, #332) Aug 8, 2022
@adofsauron adofsauron requested review from RingsC and isredstar August 8, 2022 13:29
@mergify mergify bot merged commit cd93ce1 into stoneatom:stonedb-5.7 Aug 9, 2022
xiaoguangye pushed a commit to xiaoguangye/stonedb that referenced this pull request Aug 11, 2022
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix(mtr):mtr result stonedb change to tianmu(stoneatom#359) (stoneatom#368)

* fix(mtr):mysqlpump*.test sys_stoendb to sys_tianmu

fix(mtr):fix main result stonedb to tianmu

fix(mtr):mv innodb_fts.ngram_1 to test/innodb_fts

fix(mtr):fix mtr funcs_1 stonedb to tianmu

fix(mtr):fix innodb mtr result stonedb change to tianmu

fix(mtr):fix perfschema mtr result stonedb change to tianmu

* fix(mtr):fix mtr stoendb change to tianmu

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix(tianmu): fix group_concat_max_len warning (stoneatom#338) (stoneatom#363)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

docs(stonedb): update docs and fix bugs (stoneatom#373)

* docs(Quick Deployment and Compiling Methods): update docs

Make the document more user-friendly for new users

* fix(docs): Let the official website pictures can be adaptive

* Update compile-using-ubuntu2004.md

In the install make step, add the go to directory:cd make-3.82

* Update compile-using-redhat7.md

In the install make step, add the go to directory:cd make-3.82

* Update compile-using-centos7.md

In the install make step, add the go to directory:cd make-3.82

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: haitaoguan <[email protected]>

feat(doc):doc add innodb backup to stonedb demonstrate(stoneatom#353) (stoneatom#355)

* feat(doc):doc add innodb backup to stonedb demonstrate

* fix(doc):fix mydumper and mysqldump doc

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

feat(innodb): To support compiling innodb as C++ 17(stoneatom#375) (stoneatom#376)

To support innodb is compiled as C++ 17. For now, tianmu is compiling as C++17,
and C++17 has became mainstream of C++ standard. Therefore, now, we star to support
to compile Innodb as C++17 in stonedb.

This is backport from MySQL, which commit id is: 1a8a111d8f855a31d0aeffc8f02309b2b82dd410 and bug# is #32907274

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix stonedb for optimize exists subquery and deep memory copy stoneatom#369 (stoneatom#330, stoneatom#329, stoneatom#340, stoneatom#332) (stoneatom#369)

* fix stonedb for optimize exists subquery and deep memcopy copy

* Update parameterized_filter.cpp

fix ParameterizedFilter deep copy mind memory leak

* fix subquery when this is in sql

* fix code readability and defensive

* use shallow memory when paral hash join by class DimensionGroupMultiMaterialized

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

feat(stonedb): To support gcc 9 and adds `WITH_ROCKSDB` and `WITH_MARISA` to specify where (stoneatom#377)

rocksdb and marisa installed, respectively.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix(mtr): Add test cases for NULL value select on UNIQUE constraint(stoneatom#281) (stoneatom#379)

* fix(core): Double prepare on lex unit for cts with union(stoneatom#226)

fix(core): MTR + Double prepare on lex unit for ctas with union(stoneatom#226)

* fix(mtr): Add test cases for NULL value select on UNIQUE constraint(stoneatom#281)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix bug stoneatom#342 (stoneatom#346)

Co-authored-by: dfx <duanfuxiang>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

Doc(stonedb): Added extensions deccriptions in topics related to backup and recovery for O&M Guide(stoneatom#360) (stoneatom#361)

* updated some code snippets in Install RocksDB step

Signed-off-by: xuejiao-joy <[email protected]>

* some description here

Signed-off-by: xuejiao-joy <[email protected]>

Co-authored-by: Yuting <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix(mtr): Add more ctas queries for the same bug-fix from code-analysis perspectives(stoneatom#226)
xiaoguangye added a commit to xiaoguangye/stonedb that referenced this pull request Aug 11, 2022
fix(core): MTR + Double prepare on lex unit for ctas with union(stoneatom#226)

rich doc to fix  env dependence "not found" (stoneatom#316)

fix(mtr): make the mtr passed (stoneatom#315) (stoneatom#317)

[summary]
How to run:
./mysql-test-run.pl --suite=stonedb --nowarnings --force --nocheck-testcases

1. test cases below are failed, we ignored them first:
issue410
issue415
issue433
issue446
issue515
load.test
2. Sys variables next are not set correctly, they should be added to `/mysql-test/include/default_mysqld.cnf`.
stonedb_insert_delayed = 0
stonedb_ini_allowmysqlquerypath=1

3.check-testcases: A new MTR option to enforce strict cleanup:
https://dev.mysql.com/blog-archive/fail-check-testcases-a-new-mtr-option-to-enforce-strict-cleanup

In `mtr` comment:
```
Some options that control enabling a feature for normal test runs,
can be turned off by prepending 'no' to the option, e.g. --notimer.
This applies to reorder, timer, check-testcases and warnings.
```
Currently we turn off it first to make mtr run success.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

feat(stonedb): update the copyright date time (stoneatom#321) (stoneatom#324)

fix(core): fix crash when executing sql. (stoneatom#327) (stoneatom#328)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

feat(index): Unified class member variable name with google style (stoneatom#311) (stoneatom#312)

[summary]
Class member name will be like:

class TableInfo {
  ...
 private:
  std::string table_name_;  // OK - underscore at end.
  static Pool<TableInfo>* pool_;  // OK.
};

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix(mtr):move character_set to test.character_set, fix main mtr_test and innodb mtr_test(stoneatom#277) (stoneatom#335)

* fix(mtr):fix innodb mtr and mv some test to test/innodb

* fix(mtr):move character_set to test/main/

fix(mtr):mv main mtr character_set test to test/main/cahracter_set

fix(mtr):mv myisam error mtr-test to test/main/myisam

fix(mtr):add optimizer_switch to include/default_mysqld.cnf

* fix(mtr):fix main mtr optimizer_switch amd mv some test to test/main

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix(mtr): Add more ctas queries for the same bug-fix from code-analysis perspectives(stoneatom#226)

fix bugs of stoneatom#309 and stoneatom#310 (stoneatom#313)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix(core): Double prepare on lex unit for cts with union(stoneatom#226) (stoneatom#365)

fix(core): MTR + Double prepare on lex unit for ctas with union(stoneatom#226)

fix(mtr):mtr result stonedb change to tianmu(stoneatom#359) (stoneatom#368)

* fix(mtr):mysqlpump*.test sys_stoendb to sys_tianmu

fix(mtr):fix main result stonedb to tianmu

fix(mtr):mv innodb_fts.ngram_1 to test/innodb_fts

fix(mtr):fix mtr funcs_1 stonedb to tianmu

fix(mtr):fix innodb mtr result stonedb change to tianmu

fix(mtr):fix perfschema mtr result stonedb change to tianmu

* fix(mtr):fix mtr stoendb change to tianmu

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix(tianmu): fix group_concat_max_len warning (stoneatom#338) (stoneatom#363)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

docs(stonedb): update docs and fix bugs (stoneatom#373)

* docs(Quick Deployment and Compiling Methods): update docs

Make the document more user-friendly for new users

* fix(docs): Let the official website pictures can be adaptive

* Update compile-using-ubuntu2004.md

In the install make step, add the go to directory:cd make-3.82

* Update compile-using-redhat7.md

In the install make step, add the go to directory:cd make-3.82

* Update compile-using-centos7.md

In the install make step, add the go to directory:cd make-3.82

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: haitaoguan <[email protected]>

feat(doc):doc add innodb backup to stonedb demonstrate(stoneatom#353) (stoneatom#355)

* feat(doc):doc add innodb backup to stonedb demonstrate

* fix(doc):fix mydumper and mysqldump doc

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

feat(innodb): To support compiling innodb as C++ 17(stoneatom#375) (stoneatom#376)

To support innodb is compiled as C++ 17. For now, tianmu is compiling as C++17,
and C++17 has became mainstream of C++ standard. Therefore, now, we star to support
to compile Innodb as C++17 in stonedb.

This is backport from MySQL, which commit id is: 1a8a111d8f855a31d0aeffc8f02309b2b82dd410 and bug# is #32907274

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix stonedb for optimize exists subquery and deep memory copy stoneatom#369 (stoneatom#330, stoneatom#329, stoneatom#340, stoneatom#332) (stoneatom#369)

* fix stonedb for optimize exists subquery and deep memcopy copy

* Update parameterized_filter.cpp

fix ParameterizedFilter deep copy mind memory leak

* fix subquery when this is in sql

* fix code readability and defensive

* use shallow memory when paral hash join by class DimensionGroupMultiMaterialized

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

feat(stonedb): To support gcc 9 and adds `WITH_ROCKSDB` and `WITH_MARISA` to specify where (stoneatom#377)

rocksdb and marisa installed, respectively.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix(mtr): Add test cases for NULL value select on UNIQUE constraint(stoneatom#281) (stoneatom#379)

* fix(core): Double prepare on lex unit for cts with union(stoneatom#226)

fix(core): MTR + Double prepare on lex unit for ctas with union(stoneatom#226)

* fix(mtr): Add test cases for NULL value select on UNIQUE constraint(stoneatom#281)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix bug stoneatom#342 (stoneatom#346)

Co-authored-by: dfx <duanfuxiang>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

Doc(stonedb): Added extensions deccriptions in topics related to backup and recovery for O&M Guide(stoneatom#360) (stoneatom#361)

* updated some code snippets in Install RocksDB step

Signed-off-by: xuejiao-joy <[email protected]>

* some description here

Signed-off-by: xuejiao-joy <[email protected]>

Co-authored-by: Yuting <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

fix(mtr): Add more ctas queries for the same bug-fix from code-analysis perspectives(stoneatom#226)
@Nliver Nliver added the PR-bug bug for pull request label Apr 15, 2023
@Nliver Nliver added this to the StoneDB_5.7_v1.0.0 milestone Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-bug bug for pull request
Projects
Development

Successfully merging this pull request may close these issues.

bug: slow-SQL-Q4-when subquery use exists sql on 10GB data spend 40 mininus and happen OOM on 100GB data
5 participants