Weiqing Yang created FLINK-41447:
------------------------------------

             Summary: An invalid table.exec.udf-metric.sample-interval is 
accepted at planning and puts the job in a restart loop
                 Key: FLINK-41447
                 URL: https://issues.apache.org/jira/browse/FLINK-41447
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
    Affects Versions: 2.4.0
            Reporter: Weiqing Yang
             Fix For: 2.4.0


*What happens*

With UDF metrics enabled, a {{table.exec.udf-metric.sample-interval}} of 0 or 
less is accepted when the query is submitted. The job then fails every time its 
operators open, and keeps restarting:
{noformat}
java.lang.IllegalArgumentException: UDF metric sample interval must be >= 1, 
but was 0.
{noformat}

*How to reproduce* (SQL Client, any scalar UDF, here {{MyUpper}})
{code:sql}
SET 'table.exec.udf-metric-enabled' = 'true';
SET 'table.exec.udf-metric.sample-interval' = '0';
CREATE TEMPORARY TABLE src (s STRING) WITH ('connector' = 'datagen', 
'rows-per-second' = '10');
CREATE TEMPORARY TABLE sink (a STRING) WITH ('connector' = 'blackhole');
INSERT INTO sink SELECT MyUpper(s) FROM src;
{code}
The INSERT is submitted without error. After 30 seconds the job is 
{{RESTARTING}} with 8 restarts. With {{table.exec.udf-metric-enabled}} set to 
false, the same job runs normally.

*Cause*

The planner reads the interval during code generation 
({{BridgingFunctionGenUtil#udfMetricsTermIfEnabled}}) and passes it into the 
generated operator without checking it. The check only happens in 
{{UdfMetrics#register}}, which runs when the operator opens on the TaskManager.

*Proposed fix*

Validate the interval where the planner reads it, and throw a 
{{ValidationException}} with the same message when metrics are enabled and the 
value is below 1. The query is then rejected at submission instead of 
restarting. Keep the runtime check as a safeguard.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to