You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/10/27 03:39:07 UTC

[GitHub] [flink] tsreaper commented on a change in pull request #17570: [FLINK-24654][table] Fix NPE on RetractableTopNFunction when some records were cleared by state ttl

tsreaper commented on a change in pull request #17570:
URL: https://github.com/apache/flink/pull/17570#discussion_r737077180



##########
File path: flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/rank/RetractableTopNFunction.java
##########
@@ -455,9 +464,18 @@ private boolean retractRecordWithoutRowNumber(
                     // sends the record if there is a record recently upgrades to Top-N
                     int index = Long.valueOf(rankEnd - nextRank).intValue();
                     List<RowData> inputs = dataState.get(key);
-                    RowData toAdd = inputs.get(index);
-                    collectInsert(out, toAdd);
-                    break;
+                    if (inputs == null) {
+                        // Skip the data if it's state is cleared because of state ttl.
+                        if (lenient) {
+                            LOG.warn(STATE_CLEARED_WARN_MSG);
+                        } else {
+                            throw new RuntimeException(STATE_CLEARED_WARN_MSG);
+                        }
+                    } else {
+                        RowData toAdd = inputs.get(index);
+                        collectInsert(out, toAdd);
+                        break;

Review comment:
       `break` should be in the outer `else` block starting from line 463?




-- 
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