Skip to content

[FLINK-30960] Fix a corner case oom error #77

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ public void open(int taskNumber, int numTasks) throws IOException {
if (!closed) {
try {
flush();
} catch (FlushingRuntimeException e) {
/*
* We ignore this FlushingRuntimeException, as it is
* only thrown when flushingException was assigned to,
* in a former run of this scheduler thread, in the next
* catch clause. In that case, we already have
* flushException cached, waiting for the next task
* manager thread's flush call which would throw a new
* FlushingRuntimeException causing job failure.
Copy link
Contributor

Choose a reason for hiding this comment

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

There is another case in this class where there is a flush() and is issues a RuntimeException, should we use the new Exception and catch it there as well; or can this case never loop. There are other calls to flush() - do we think these are not effected?

Copy link
Author

Choose a reason for hiding this comment

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

I see, the close method calls flush as well. In this case, the scheduler is already shutdown before calling flush, so it will never loop.

It won't hurt if we throw the new FlushingRuntimeException here instead, as it will propagate up to be handled by TaskManager the same way as a regular RuntimeException.

*/
} catch (Exception e) {
flushException = e;
}
Expand All @@ -178,7 +188,7 @@ private JdbcExec createAndOpenStatementExecutor(

private void checkFlushException() {
if (flushException != null) {
throw new RuntimeException("Writing records to JDBC failed.", flushException);
throw new FlushingRuntimeException("Writing records to JDBC failed.", flushException);
}
}

Expand Down Expand Up @@ -415,4 +425,12 @@ public JdbcExecutionOptions getExecutionOptions() {
public Connection getConnection() {
return connectionProvider.getConnection();
}

static class FlushingRuntimeException extends RuntimeException {
private static final long serialVersionUID = -8923632392030344592L;

FlushingRuntimeException(String msg, Exception cause) {
super(msg, cause);
}
}
}