[
https://issues.apache.org/jira/browse/FLINK-16597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17061249#comment-17061249
]
Roman Khachatryan commented on FLINK-16597:
-------------------------------------------
Some additional observations:
# `OutputFormatSinkFunction` also firstly closes and then (if `close`
errored) calls `tryCleanupOnError`
# `DataSinkTask#invoke` contains 2 `close` calls (1st one just before catch)
OutputFormatSinkFunction behavior looks right to me because interface
`CleanupWhenUnsuccessful` specifies that it should be called in case of *any*
error including in `close`.
So I'd propose to
# `DataSinkTask#invoke`
## remove 2nd close call
## put 1st one into the new nested finally
## preserve original exception (if close throws itself) - ideally by adding
suppressed
## wrap exception thrown from close (instead of logging)
## don't check if task was cancelled
# `DataSinkTask#cancel`: don't swallow exception; move tryCleanupOnError
inside catch block
> tryCleanupOnError should happen before close
> --------------------------------------------
>
> Key: FLINK-16597
> URL: https://issues.apache.org/jira/browse/FLINK-16597
> Project: Flink
> Issue Type: Improvement
> Components: Runtime / Task
> Affects Versions: 1.10.0
> Reporter: Jiayi Liao
> Priority: Major
>
> If {{DataSinkTask}} fails or throws an exception, the {{OutputFormat}} will
> call {{tryCleanupOnError}} before {{close}}. But the calling order is reverse
> when {{DataSinkTask}} is cancelled, which doesn't make much sense that we can
> still clean the output format after it's closed.
> I'm not very sure if this is a bug. But this does mislead our developers when
> implementing our customized {{OutputFormat}}. cc [~sewen]
--
This message was sent by Atlassian Jira
(v8.3.4#803005)