-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](delete) fix delete from bug which can get wrong result #17146
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
Conversation
|
clang-tidy review says "All clean, LGTM! 👍" |
|
clang-tidy review says "All clean, LGTM! 👍" |
1 similar comment
|
clang-tidy review says "All clean, LGTM! 👍" |
|
run buildall |
| RETURN_IF_ERROR(_column_iterators[_schema.unique_id(cid)]->get_row_ranges_by_zone_map( | ||
| _opts.col_id_to_predicates[cid].get(), | ||
| _opts.col_id_to_del_predicates.count(cid) > 0 | ||
| _opts.col_id_to_del_predicates.size() == 1 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If user send to delete predicates:
- delete where a = 1
- delete where a = 2
In this pr, the delete predicate will take no effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
理论上,如果是两次独立的删除,比如delete from table where a=1; delete from table where a=2;其实这个地方应该可以使用的,但是目前的代码,是把所有不同版本的delete predicates和不同列的delete predicates都放到一起了,失去了版本信息、失去了谓词间可能是and的关系,统一弱化成了delete predicates都是独立的,有一个delete predicates满足条件,就把page都去掉。
这个pr的修改方式,就是在当前代码的基础上,当只有一个delete predicate的时候才能保证后续淘汰page的正确性,所以这里一律加了 == 1的判断才传递delete predicates。
如果要把不同版本的delete predicates和不同列的delete predicates作为完整和严谨的逻辑去判断page,需要修改的设计就有点多了,目前的方案算是一种优先解决bug的思路,后续可以进一步把delete predicates这块加速zone判断进行page淘汰的逻辑完善,提高delete predicates使用的场景。
| "in_memory" = "false", | ||
| "storage_format" = "V2", | ||
| "light_schema_change" = "true", | ||
| "disable_auto_compaction" = "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think should disable auto compaction, then p0 could produce stable result. If disable auto compaction == false, the rowset maybe merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,let me fix this test
| RETURN_IF_ERROR(_column_iterators[_schema.unique_id(cid)]->get_row_ranges_by_zone_map( | ||
| _opts.col_id_to_predicates[cid].get(), | ||
| _opts.col_id_to_del_predicates.count(cid) > 0 | ||
| _opts.col_id_to_del_predicates.size() == 1 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment here to explain these conditions. For example, why check size == 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i add a comment
|
run buildall |
|
clang-tidy review says "All clean, LGTM! 👍" |
| // 统一弱化成了delete predicates都是独立的,有一个delete predicates满足条件,就把page都去掉。 | ||
| // 这个pr的修改方式,就是在当前代码的基础上,当只有一个delete predicate的时候才能保证后续淘汰page的正确性,所以这里一律加了 == 1的判断才传递delete predicates。 | ||
| // 如果要把不同版本的delete predicates和不同列的delete predicates作为完整和严谨的逻辑去判断page,需要修改的设计就有点多了, | ||
| // 目前的方案算是一种优先解决bug的思路,后续可以进一步把delete predicates这块加速zone判断进行page淘汰的逻辑完善,提高delete predicates使用的场景。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please compact the comment and in English.
For example:
Currently, one transaction can only support one delete condition for page filtering.
Following case is allowed:
delete from table1 where a=1;
delete from table1 where a=2;
Following case is not allowed, because one transaction has more than on delete condition:
delete from table1 where a=1 and b = 2;
This may cause bug when you query table1 with a=1;
You can refer #17145 for more details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please compact the comment and in English. For example:
Currently, one transaction can only support one delete condition for page filtering. Following case is allowed: delete from table1 where a=1; delete from table1 where a=2; Following case is not allowed, because one transaction has more than on delete condition: delete from table1 where a=1 and b = 2; This may cause bug when you query table1 with a=1; You can refer #17145 for more details.
thanks bro, you are my hero
|
run buildall |
|
clang-tidy review says "All clean, LGTM! 👍" |
| RETURN_IF_ERROR(_column_iterators[_schema.unique_id(cid)]->get_row_ranges_by_zone_map( | ||
| _opts.col_id_to_predicates[cid].get(), | ||
| _opts.col_id_to_del_predicates.count(cid) > 0 | ||
| // Currently, one transaction can only support one delete condition for page filtering. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that when delete condition only contains OR predicates, page filter can work correctly here.
So this pr is a quick fix, it may cause some case performance degradation.
I think it's better to add a todo here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i add a todo
|
|
||
| sql """delete from ${tableName} where k2 is not null and k3=11;""" | ||
|
|
||
| qt_sql """select k2,k3 from ${tableName};""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd better add order by in query sql.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is better, lei fix it
wangbo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
run buildall |
|
PR approved by anyone and no changes requested. |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
run COMPILE |
|
run buildall |
Signed-off-by: nextdreamblue <zxw520blue1@163.com>
Signed-off-by: nextdreamblue <zxw520blue1@163.com>
Signed-off-by: nextdreamblue <zxw520blue1@163.com>
Signed-off-by: nextdreamblue <zxw520blue1@163.com>
Signed-off-by: nextdreamblue <zxw520blue1@163.com>
Signed-off-by: nextdreamblue <zxw520blue1@163.com>
Signed-off-by: nextdreamblue <zxw520blue1@163.com>
3a4297a to
97a9a0d
Compare
|
clang-tidy review says "All clean, LGTM! 👍" |
Signed-off-by: nextdreamblue <zxw520blue1@163.com>
Signed-off-by: nextdreamblue <zxw520blue1@163.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
1 similar comment
|
clang-tidy review says "All clean, LGTM! 👍" |
|
run buildall |
yiguolei
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
PR approved by at least one committer and no changes requested. |
理论上,如果是两次独立的删除,比如delete from table where a=1; delete from table where a=2;其实这个地方应该可以使用的,但是目前的代码,是把所有不同版本的delete predicates和不同列的delete predicates都放到一起了,失去了版本信息、失去了谓词间可能是and的关系,统一弱化成了delete predicates都是独立的,有一个delete predicates满足条件,就把page都去掉。 这个pr的修改方式,就是在当前代码的基础上,当只有一个delete predicate的时候才能保证后续淘汰page的正确性,所以这里一律加了 == 1的判断才传递delete predicates。 如果要把不同版本的delete predicates和不同列的delete predicates作为完整和严谨的逻辑去判断page,需要修改的设计就有点多了,目前的方案算是一种优先解决bug的思路,后续可以进一步把delete predicates这块加速zone判断进行page淘汰的逻辑完善,提高delete predicates使用的场景。
fix cherry-pick bug of #17146
…17146) 理论上,如果是两次独立的删除,比如delete from table where a=1; delete from table where a=2;其实这个地方应该可以使用的,但是目前的代码,是把所有不同版本的delete predicates和不同列的delete predicates都放到一起了,失去了版本信息、失去了谓词间可能是and的关系,统一弱化成了delete predicates都是独立的,有一个delete predicates满足条件,就把page都去掉。 这个pr的修改方式,就是在当前代码的基础上,当只有一个delete predicate的时候才能保证后续淘汰page的正确性,所以这里一律加了 == 1的判断才传递delete predicates。 如果要把不同版本的delete predicates和不同列的delete predicates作为完整和严谨的逻辑去判断page,需要修改的设计就有点多了,目前的方案算是一种优先解决bug的思路,后续可以进一步把delete predicates这块加速zone判断进行page淘汰的逻辑完善,提高delete predicates使用的场景。
* [fix](delete) fix delete from bug which can get wrong result (apache#17146) 理论上,如果是两次独立的删除,比如delete from table where a=1; delete from table where a=2;其实这个地方应该可以使用的,但是目前的代码,是把所有不同版本的delete predicates和不同列的delete predicates都放到一起了,失去了版本信息、失去了谓词间可能是and的关系,统一弱化成了delete predicates都是独立的,有一个delete predicates满足条件,就把page都去掉。 这个pr的修改方式,就是在当前代码的基础上,当只有一个delete predicate的时候才能保证后续淘汰page的正确性,所以这里一律加了 == 1的判断才传递delete predicates。 如果要把不同版本的delete predicates和不同列的delete predicates作为完整和严谨的逻辑去判断page,需要修改的设计就有点多了,目前的方案算是一种优先解决bug的思路,后续可以进一步把delete predicates这块加速zone判断进行page淘汰的逻辑完善,提高delete predicates使用的场景。 * [fix](delete) fix 'is null' or 'is not null' delete predicate will get wrong result (apache#17190) fix 'is null' or 'is not null' delete predicate will get wrong result Signed-off-by: nextdreamblue <zxw520blue1@163.com> --------- Signed-off-by: nextdreamblue <zxw520blue1@163.com> Co-authored-by: xueweizhang <zxw520blue1@163.com>
* [fix](delete) fix delete from bug which can get wrong result (apache#17146) 理论上,如果是两次独立的删除,比如delete from table where a=1; delete from table where a=2;其实这个地方应该可以使用的,但是目前的代码,是把所有不同版本的delete predicates和不同列的delete predicates都放到一起了,失去了版本信息、失去了谓词间可能是and的关系,统一弱化成了delete predicates都是独立的,有一个delete predicates满足条件,就把page都去掉。 这个pr的修改方式,就是在当前代码的基础上,当只有一个delete predicate的时候才能保证后续淘汰page的正确性,所以这里一律加了 == 1的判断才传递delete predicates。 如果要把不同版本的delete predicates和不同列的delete predicates作为完整和严谨的逻辑去判断page,需要修改的设计就有点多了,目前的方案算是一种优先解决bug的思路,后续可以进一步把delete predicates这块加速zone判断进行page淘汰的逻辑完善,提高delete predicates使用的场景。 * [fix](delete) fix 'is null' or 'is not null' delete predicate will get wrong result (apache#17190) fix 'is null' or 'is not null' delete predicate will get wrong result Signed-off-by: nextdreamblue <zxw520blue1@163.com> --------- Signed-off-by: nextdreamblue <zxw520blue1@163.com> Co-authored-by: xueweizhang <zxw520blue1@163.com>
Proposed changes
Issue Number: close #17145
Problem summary
Describe your changes.
Checklist(Required)
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...