Skip to content

Fix potential infinite loop at IterativeOptimizer with Iceberg#20007

Merged
raunaqmorarka merged 1 commit intotrinodb:masterfrom
assaf2:assaf2-os/remove-condition
Dec 6, 2023
Merged

Fix potential infinite loop at IterativeOptimizer with Iceberg#20007
raunaqmorarka merged 1 commit intotrinodb:masterfrom
assaf2:assaf2-os/remove-condition

Conversation

@assaf2
Copy link
Member

@assaf2 assaf2 commented Dec 4, 2023

Description

Remove a condition that can potentially lead to an infinite loop at IterativeOptimizer.
When this condition was added, constraint.getPredicateColumns() was always empty when the rule was running within iterative optimizer (see discussion at https://github.com/trinodb/trino/pull/17263/files#r1189575899) but this is not the case since https://github.com/trinodb/trino/pull/16019/files#diff-624ea155d75175ba8802d5f93af759bdb88c6f63f1ca9660d6704892e1033f1dR814-R825. According to my check, we don't see an infinite loop only because io.trino.sql.planner.iterative.rule.PushPredicateIntoTableScan#arePlansSame returns true and stops the iterative process. If in the future io.trino.plugin.iceberg.IcebergTableHandle#equals will return false when comparing 2 tables of 2 different iterations, then we'll see an infinite loop. That's while io.trino.spi.connector.ConnectorTableHandle is an empty interface that doesn't declare equals().

Additional context and related issues

19876

Release notes

( X ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

@cla-bot cla-bot bot added the cla-signed label Dec 4, 2023
@github-actions github-actions bot added the iceberg Iceberg connector label Dec 4, 2023
@assaf2 assaf2 requested review from Praveen2112, alexjo2144, findepi, marton-bod, raunaqmorarka and sopel39 and removed request for findepi December 4, 2023 09:29
@assaf2 assaf2 self-assigned this Dec 4, 2023
@assaf2 assaf2 marked this pull request as ready for review December 4, 2023 09:33
@assaf2 assaf2 requested review from ebyhr and findinpath December 5, 2023 13:04
Copy link
Member

@sopel39 sopel39 left a comment

Choose a reason for hiding this comment

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

lgtm % but I would like someone more familiar with code to take a look. What about test?

Copy link
Contributor

@marton-bod marton-bod left a comment

Choose a reason for hiding this comment

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

LGTM - @zhangminglei can you also take a look? This concerns the change to the applyFilter method

if (newEnforcedConstraint.equals(table.getEnforcedPredicate())
&& newUnenforcedConstraint.equals(table.getUnenforcedPredicate())
&& newConstraintColumns.equals(table.getConstraintColumns())
&& constraint.getPredicateColumns().isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

@marton-bod / @zhengxingmao - What was the initial reason for adding a check on constraint.getPredicateColumns().isEmpty() - Ideally the applyFilter should depends on the IcebergTableHandle state after applying the filter and not based on Constraint's state

@assaf2
Copy link
Member Author

assaf2 commented Dec 5, 2023

lgtm % but I would like someone more familiar with code to take a look. What about test?

I don't know why this condition was added in the first place, so since I don't see its necessity, I'm not sure how to test its removal

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

Labels

cla-signed iceberg Iceberg connector

Development

Successfully merging this pull request may close these issues.

5 participants