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

[FLINK-28899][table-planner] Fix LOOKUP hint with retry option on async lookup mode #20531

Closed
wants to merge 2 commits into from

Conversation

lincoln-lil
Copy link
Contributor

What is the purpose of the change

FLINK-28848 introduces a new LOOKUP hint to support retry both on sync and async lookup, but the async path doesn't works because of two reasons: 1. AsyncLookupJoinRunner has a 'stateful' resultFutureBuffer (which is very important for performance) bind to each input record (it's non-reenter-able) 2. can not lookup new value if cache empty values enabled when chained with the new AsyncCachingLookupFunction. So this can not be done by directly enabling retry on 'AsyncWaitOperator', so similar to sync lookup join with retry, we fix this by using a 'RetryableAsyncLookupFunctionDelegator' to support retry.

Brief change log

  • fix async lookup it case with retry
  • add new RetryableAsyncLookupFunctionDelegator

Verifying this change

  • RetryableAsyncLookupFunctionDelegatorTest
  • AsyncLookupJoinITCase

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @public(Evolving): (no)
  • The serializers: (no )
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (no)

@flinkbot
Copy link
Collaborator

flinkbot commented Aug 10, 2022

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

Copy link
Contributor

@godfreyhe godfreyhe left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, I left some comments

*
* @return the UserDefinedFunction by preferable lookup mode, if require
* <pre>{@code
* 1. if upsertMaterialize == true : require sync lookup orElse error
Copy link
Contributor

Choose a reason for hiding this comment

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

or else ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment on lines 45 to 46
this.userLookupFunction = userLookupFunction;
this.retryStrategy = retryStrategy;
Copy link
Contributor

Choose a reason for hiding this comment

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

please do some null check for given arguments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add checkNotNull

Comment on lines 88 to 93
public void open(FunctionContext context) throws Exception {
super.open(context);
userLookupFunction.open(context);
retryResultPredicate =
retryStrategy.getRetryPredicate().resultPredicate().orElse(ignore -> false);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the open method can be moved to after constructor

});

@Test
public void testLookupWithRetry() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add more tests to cover the branches:

  1. retryEnabled is disabled
  2. different ResultRetryStrategy
  3. ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add tests cover the case retry disabled, and also a custom result retry strategy using exponential backoff delay (though we only support fixed delay in sql for now)

Copy link
Contributor Author

@lincoln-lil lincoln-lil left a comment

Choose a reason for hiding this comment

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

@godfreyhe thank you for reviewing this! I've addressed all your comments and updated this pr.

*
* @return the UserDefinedFunction by preferable lookup mode, if require
* <pre>{@code
* 1. if upsertMaterialize == true : require sync lookup orElse error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment on lines 45 to 46
this.userLookupFunction = userLookupFunction;
this.retryStrategy = retryStrategy;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add checkNotNull

});

@Test
public void testLookupWithRetry() throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add tests cover the case retry disabled, and also a custom result retry strategy using exponential backoff delay (though we only support fixed delay in sql for now)

Copy link
Contributor

@godfreyhe godfreyhe left a comment

Choose a reason for hiding this comment

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

LGTM

@godfreyhe godfreyhe closed this in cd173e7 Aug 16, 2022
huangxiaofeng10047 pushed a commit to huangxiaofeng10047/flink that referenced this pull request Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants