You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "xuyangzhong (via GitHub)" <gi...@apache.org> on 2025/07/04 08:11:24 UTC
[PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
xuyangzhong opened a new pull request, #26752:
URL: https://github.com/apache/flink/pull/26752
## What is the purpose of the change
This pr aims to do two things:
1. tell us what happens in `StreamingDeltaJoinOperatorTest` instead of hanging the CI
2. this pr is also trying to fix the potential bugs causing the hang for `ConcurrentModificationException` while copying list in tests

## Brief change log
- *Collect exceptions when doing delta join*
- *Avoid ConcurrentModificationException when copying list*
## Verifying this change
New and existent tests can cover this pr.
## 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
- If yes, how is the feature documented?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong merged PR #26752:
URL: https://github.com/apache/flink/pull/26752
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2188902859
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -679,11 +730,23 @@ public static void release() {
Objects.requireNonNull(lock).countDown();
}
+ public static void throwException(Throwable t) {
Review Comment:
Good catch!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2188898554
##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/testutils/MockEnvironment.java:
##########
@@ -483,4 +491,8 @@ public void setExpectedExternalFailureCause(Class<? extends Throwable> expectedT
public Optional<? extends Throwable> getActualExternalFailureCause() {
return actualExternalFailureCause;
}
+
+ public void setExternalFailureCauseConsumer(Consumer<Throwable> externalFailureCauseConsumer) {
Review Comment:
Actually we can't use `expectedExternalFailureCause ` because it will fail again if there are two exceptions thrown into `MockEnvironment#failExternally` and cause `checkState(!actualExternalFailureCause.isPresent());` failed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "Au-Miner (via GitHub)" <gi...@apache.org>.
Au-Miner commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2184917402
##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/testutils/MockEnvironment.java:
##########
@@ -483,4 +491,8 @@ public void setExpectedExternalFailureCause(Class<? extends Throwable> expectedT
public Optional<? extends Throwable> getActualExternalFailureCause() {
return actualExternalFailureCause;
}
+
+ public void setExternalFailureCauseConsumer(Consumer<Throwable> externalFailureCauseConsumer) {
Review Comment:
There is expectedExternalFailureCause we can use in MockEnvironment, so we needn't create externalFailureCauseConsumer to consume the exception.
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -155,12 +157,22 @@ VarCharType.STRING_TYPE, new IntType(), new BooleanType()
private RowDataHarnessAssertor assertor;
+ private Optional<Throwable> latestException = Optional.empty();
+
@BeforeEach
public void beforeEach() throws Exception {
testHarness = createDeltaJoinOperatorTestHarness();
testHarness.setup();
testHarness.open();
StreamingDeltaJoinOperator operator = unwrapOperator(testHarness);
+ // set external failure cause consumer to prevent hang
+ testHarness
+ .getEnvironment()
+ .setExternalFailureCauseConsumer(
Review Comment:
Maybe we can use setExpectedExternalFailureCause instead of setExternalFailureCauseConsumer.
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -529,6 +547,33 @@ void testClearLegacyStateWhenCheckpointing() throws Exception {
"result mismatch", expectedOutput, testHarness.getOutput());
}
+ @Test
+ void testMeetExceptionWhenLookup() throws Exception {
+ Throwable expectedException = new IllegalStateException("Mock to fail");
+ MyAsyncFunction.throwException(expectedException);
+
+ StreamRecord<RowData> record = insertRecord(100, true, "jklk1");
+ testHarness.processElement1(record);
+
+ // IllegalStateException(Failed to wait all data processed)
+ // +- Exception(Could not complete the stream element ...)
+ // +- RuntimeException(Failed to lookup table)
+ // +- Actual Exception
+ assertThatThrownBy(this::waitAllDataProcessed)
+ .cause()
+ .cause()
+ .cause()
+ .isEqualTo(expectedException);
+ }
+
+ private void waitAllDataProcessed() throws Exception {
+ testHarness.endAllInputs();
+ if (latestException.isPresent()) {
Review Comment:
Correspondingly, we can use getActualExternalFailureCause().isPresent() to judge if we should throw exception here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2188899220
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -155,12 +157,22 @@ VarCharType.STRING_TYPE, new IntType(), new BooleanType()
private RowDataHarnessAssertor assertor;
+ private Optional<Throwable> latestException = Optional.empty();
+
@BeforeEach
public void beforeEach() throws Exception {
testHarness = createDeltaJoinOperatorTestHarness();
testHarness.setup();
testHarness.open();
StreamingDeltaJoinOperator operator = unwrapOperator(testHarness);
+ // set external failure cause consumer to prevent hang
+ testHarness
+ .getEnvironment()
+ .setExternalFailureCauseConsumer(
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2188900653
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -529,6 +547,33 @@ void testClearLegacyStateWhenCheckpointing() throws Exception {
"result mismatch", expectedOutput, testHarness.getOutput());
}
+ @Test
+ void testMeetExceptionWhenLookup() throws Exception {
Review Comment:
I think it is not necessary because I just want to test that the expected exception should be thrown. The inserted record is only used to trigger to throw the exception.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong commented on PR #26752:
URL: https://github.com/apache/flink/pull/26752#issuecomment-3034940342
@Au-Miner Can you please take a look at this pr?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2188898554
##########
flink-runtime/src/test/java/org/apache/flink/runtime/operators/testutils/MockEnvironment.java:
##########
@@ -483,4 +491,8 @@ public void setExpectedExternalFailureCause(Class<? extends Throwable> expectedT
public Optional<? extends Throwable> getActualExternalFailureCause() {
return actualExternalFailureCause;
}
+
+ public void setExternalFailureCauseConsumer(Consumer<Throwable> externalFailureCauseConsumer) {
Review Comment:
Actually we can't use `expectedExternalFailureCause ` because if there are two exceptions thrown into `MockEnvironment#failExternally`, `checkState(!actualExternalFailureCause.isPresent());` will fail again
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "Au-Miner (via GitHub)" <gi...@apache.org>.
Au-Miner commented on PR #26752:
URL: https://github.com/apache/flink/pull/26752#issuecomment-3035297274
Thanks for improving the testing code logic!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2188899423
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -529,6 +547,33 @@ void testClearLegacyStateWhenCheckpointing() throws Exception {
"result mismatch", expectedOutput, testHarness.getOutput());
}
+ @Test
+ void testMeetExceptionWhenLookup() throws Exception {
+ Throwable expectedException = new IllegalStateException("Mock to fail");
+ MyAsyncFunction.throwException(expectedException);
+
+ StreamRecord<RowData> record = insertRecord(100, true, "jklk1");
+ testHarness.processElement1(record);
+
+ // IllegalStateException(Failed to wait all data processed)
+ // +- Exception(Could not complete the stream element ...)
+ // +- RuntimeException(Failed to lookup table)
+ // +- Actual Exception
+ assertThatThrownBy(this::waitAllDataProcessed)
+ .cause()
+ .cause()
+ .cause()
+ .isEqualTo(expectedException);
+ }
+
+ private void waitAllDataProcessed() throws Exception {
+ testHarness.endAllInputs();
+ if (latestException.isPresent()) {
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "xuyangzhong (via GitHub)" <gi...@apache.org>.
xuyangzhong commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2188901784
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperator.java:
##########
@@ -143,9 +143,10 @@ public class StreamingDeltaJoinOperator
private final boolean[] isInputEnded;
- // ---------------------------- Metrics -----------------------------------
Review Comment:
The `totalInflightNum` is not only a metric but also related to operator logic such as `tryProcess`, `allInflightFinished`, etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #26752:
URL: https://github.com/apache/flink/pull/26752#issuecomment-3034947142
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b13c51e0181bb4d46cd5681fa4cd5238684f9136",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "b13c51e0181bb4d46cd5681fa4cd5238684f9136",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b13c51e0181bb4d46cd5681fa4cd5238684f9136 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "Au-Miner (via GitHub)" <gi...@apache.org>.
Au-Miner commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2185014848
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -529,6 +547,33 @@ void testClearLegacyStateWhenCheckpointing() throws Exception {
"result mismatch", expectedOutput, testHarness.getOutput());
}
+ @Test
+ void testMeetExceptionWhenLookup() throws Exception {
Review Comment:
We can also enrich the situations where errors occur, such as multiple insert records and throwing exceptions midway
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2185037147
##########
flink-table/flink-table-runtime/src/test/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperatorTest.java:
##########
@@ -679,11 +730,23 @@ public static void release() {
Objects.requireNonNull(lock).countDown();
}
+ public static void throwException(Throwable t) {
Review Comment:
nit: throwException implied it will throw an Exception. I suggest rename to `setExpectedThrownException `or storeException
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38022][table] Throw exception in main thread in tests when any exception is thrown in async thread during looking up [flink]
Posted by "davidradl (via GitHub)" <gi...@apache.org>.
davidradl commented on code in PR #26752:
URL: https://github.com/apache/flink/pull/26752#discussion_r2185031028
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/deltajoin/StreamingDeltaJoinOperator.java:
##########
@@ -143,9 +143,10 @@ public class StreamingDeltaJoinOperator
private final boolean[] isInputEnded;
- // ---------------------------- Metrics -----------------------------------
Review Comment:
nit: why did we move this line , it seemed to fine where it was - I assume `totalInflightNum ` is a metric
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org