Skip to content

Conversation

@jacktengg
Copy link
Contributor

@jacktengg jacktengg commented Aug 22, 2022

Proposed changes

Issue Number: close #xxx

Problem summary

For debug purpose:
Add session variable skip_storage_engine_merge, when set to true, tables of aggregate key model and unique key model will be read as duplicate key model.
Add session variable skip_delete_predicate, when set to true, rows deleted with delete statement will be selected.

Test result( withc auto compaction off):

create test table and insert data:

drop table if exists t1;
create table t1(a int, b int) engine = olap unique key (a) distributed by hash(a) buckets 16 properties("replication_allocation" = "tag.location.default:1");

insert into t1 values (1,1),(2,1);
insert into t1 values (1,11),(2,11);
insert into t1 values (3,1);

initial session variables and data:

mysql> show variables like "%skip%";
+---------------------------+-------+
| Variable_name             | Value |
+---------------------------+-------+
| skip_delete_predicate     | false |
| skip_storage_engine_merge | false  |
+---------------------------+-------+
2 rows in set (0.00 sec)

mysql> show variables like "%hidd%";
+---------------------+-------+
| Variable_name       | Value |
+---------------------+-------+
| show_hidden_columns | false |
+---------------------+-------+
1 row in set (0.00 sec)

mysql> select * from t1;
+------+------+
| a    | b    |
+------+------+
|    1 |   11 |
|    2 |   11 |
|    3 |    1 |
+------+------+
3 rows in set (0.50 sec)

enable skip_storage_engine_merge and check select result, not merged original rows are returned:

mysql> set skip_storage_engine_merge = true;
Query OK, 0 rows affected (0.01 sec)

mysql> select * from t1;
+------+------+-----------------------+
| a    | b    | __DORIS_DELETE_SIGN__ |
+------+------+-----------------------+
|    3 |    1 |                     0 |
|    2 |    1 |                     0 |
|    2 |   11 |                     0 |
|    1 |    1 |                     0 |
|    1 |   11 |                     0 |
+------+------+-----------------------+
5 rows in set (0.04 sec)

turn off skip_storage_engine_merge

mysql> set skip_storage_engine_merge = false;

load delete and select again:
csv:

1|111
curl --location-trusted -uroot: -H "column_separator:|" -H "columns:a, b" -H "merge_type: delete" -T delete.csv http://127.0.0.1:8030/api/test_skip/t1/_stream_load

mysql> select * from t1;
+------+------+
| a    | b    |
+------+------+
|    3 |    1 |
|    2 |   11 |
+------+------+
2 rows in set (0.05 sec)

delete rows with a = 2:

mysql> delete from t1 where a = 2;
Query OK, 0 rows affected (0.09 sec)
{'label':'delete_3b7fc2c3-becb-4586-bc46-dc225274186d', 'status':'VISIBLE', 'txnId':'30049'}

mysql> select * from t1;
+------+------+
| a    | b    |
+------+------+
|    3 |    1 |
+------+------+
1 row in set (0.04 sec)

enable skip_storage_engine_merge and select, rows deleted with delete statement is not returned:

mysql> set skip_storage_engine_merge = true;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from t1;
+------+------+-----------------------+
| a    | b    | __DORIS_DELETE_SIGN__ |
+------+------+-----------------------+
|    3 |    1 |                     0 |
|    1 |    1 |                     0 |
|    1 |   11 |                     0 |
|    1 |  111 |                     1 |
+------+------+-----------------------+
4 rows in set (0.04 sec)

enable skip_delete_predicate, rows deleted with delete statement is also returned:

mysql> set skip_delete_predicate = true;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from t1;
+------+------+-----------------------+
| a    | b    | __DORIS_DELETE_SIGN__ |
+------+------+-----------------------+
|    3 |    1 |                     0 |
|    2 |    1 |                     0 |
|    2 |   11 |                     0 |
|    1 |    1 |                     0 |
|    1 |   11 |                     0 |
|    1 |  111 |                     1 |
+------+------+-----------------------+
6 rows in set (0.03 sec)

Checklist(Required)

  1. Does it affect the original behavior:
    • Yes
    • No
    • I don't know
  2. Has unit tests been added:
    • Yes
    • No
    • No Need
  3. Has document been added or modified:
    • Yes
    • No
    • No Need
  4. Does it need to update dependencies:
    • Yes
    • No
  5. Are there any changes that cannot be rolled back:
    • Yes (If Yes, please explain WHY)
    • No

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@github-actions github-actions bot added area/vectorization kind/docs Categorizes issue or PR as related to documentation. labels Aug 22, 2022
* For debugg purpose, dont' merge unique key and agg key when reading data.
*/
@VariableMgr.VarAttr(name = AGG_AS_DUPLICATE)
private boolean aggAsDuplicate = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

the variable name: skip_storage_engine_merge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@VariableMgr.VarAttr(name = AGG_AS_DUPLICATE)
private boolean aggAsDuplicate = false;

public String getBlockEncryptionMode() {
Copy link
Contributor

Choose a reason for hiding this comment

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

also add another variable: skip_delete_predicate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

->rowset_meta()
->is_segments_overlapping());

_tablet_reader_params.direct_mode = _aggregation || single_version;
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is useless?

yiguolei
yiguolei previously approved these changes Aug 22, 2022
Copy link
Contributor

@yiguolei yiguolei left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Aug 22, 2022
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@github-actions github-actions bot removed the approved Indicates a PR has been approved by one committer. label Aug 22, 2022
* For debugg purpose, skip delte predicate when reading data.
*/
@VariableMgr.VarAttr(name = SKIP_DELETE_PREDICATE)
private boolean skipDeletePredicate = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

use public, or it may cause some serde probem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

* For debugg purpose, dont' merge unique key and agg key when reading data.
*/
@VariableMgr.VarAttr(name = SKIP_STORAGE_ENGINE_MERGE)
private boolean skipStorageEngineMerge = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is true, can we select DELETE_SIGN directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

…skip_storage_engine_merge` to treat agg and unique data model as dup model

Also `skip_delete_predicate` session variable to skep delete predicates when reading table data.
Copy link
Contributor

@yiguolei yiguolei left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Sep 13, 2022
@yiguolei yiguolei merged commit 6bf5fc6 into apache:master Sep 13, 2022
jacktengg added a commit to jacktengg/incubator-doris that referenced this pull request Sep 26, 2022
…ms: add session variable skip_storage_engine_merge to treat agg and unique data model as dup model (apache#11952)

For debug purpose:
Add session variable skip_storage_engine_merge, when set to true, tables
of aggregate key model and unique key model will be read as duplicate
key model.
Add session variable skip_delete_predicate, when set to true, rows
deleted with delete statement will be selected.
@morningman morningman mentioned this pull request Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/vectorization dev/merged-1.1.3-deprecated kind/docs Categorizes issue or PR as related to documentation. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants