You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "gustavodemorais (via GitHub)" <gi...@apache.org> on 2026/08/06 08:21:13 UTC

[PR] [FLINK-40339][table] Do not read buffer entries after removing them [flink]

gustavodemorais opened a new pull request, #28933:
URL: https://github.com/apache/flink/pull/28933

   ## What is the purpose of the change
   
   WatermarkCompactingSinkMaterializer removed buffer entries while iterating and read their values afterwards. The value of a Map.Entry is undefined once the entry has been removed, and RocksDBMapEntry returns null for it, so consolidation on restore only works because the heap backend keeps removed values readable.
   
   ## Brief change log
   
   - Consume all buffered values in consolidateBufferToMinValue before mutating the buffer, and drop it with a single clear()
   - Iterate values() instead of entries() in the ordered branch
   
   ## Verifying this change
   
   - WatermarkCompactingSinkMaterializerTest
   
   ## 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 - consolidation runs at most once per key per restore
   - 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? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [x] Yes (please specify the tool below)
   
   2.1.220 (Claude Code) with Opus 5


-- 
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-40339][table] Do not read buffer entries after removing them [flink]

Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on PR #28933:
URL: https://github.com/apache/flink/pull/28933#issuecomment-5203507289

   Hey @geeknarrator, our only state backend that tests this code is heap which already worked accidentally. Didn’t find a clean way to add additional testing without a adding a load of bloat but the current tests passing is a good coverage. If you have a good/clean suggestion on how to test this, let me know


-- 
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-40339][table] Do not read buffer entries after removing them [flink]

Posted by "rkhachatryan (via GitHub)" <gi...@apache.org>.
rkhachatryan commented on code in PR #28933:
URL: https://github.com/apache/flink/pull/28933#discussion_r3727750182


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/sink/WatermarkCompactingSinkMaterializer.java:
##########
@@ -231,6 +224,9 @@ private void consolidateBufferToMinValue() throws Exception {
             }
         }
 
+        // Clear only after all values were read.
+        buffer.clear();

Review Comment:
   This is simpler indeed, but RocksDB opens a new iterator here IIRC.
   Opening an iterator is quite expensive, so this might cause a performance regression.



-- 
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-40339][table] Do not read buffer entries after removing them [flink]

Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #28933:
URL: https://github.com/apache/flink/pull/28933#discussion_r3727904110


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/sink/WatermarkCompactingSinkMaterializer.java:
##########
@@ -231,6 +224,9 @@ private void consolidateBufferToMinValue() throws Exception {
             }
         }
 
+        // Clear only after all values were read.
+        buffer.clear();

Review Comment:
   Ops, that is not correct. I just went with the delete approach which means also less changes



-- 
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-40339][table] Do not read buffer entries after removing them [flink]

Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais commented on code in PR #28933:
URL: https://github.com/apache/flink/pull/28933#discussion_r3727808693


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/sink/WatermarkCompactingSinkMaterializer.java:
##########
@@ -231,6 +224,9 @@ private void consolidateBufferToMinValue() throws Exception {
             }
         }
 
+        // Clear only after all values were read.
+        buffer.clear();

Review Comment:
   This is the branch for the unordered state backends - so Rocksdb is not affected by the change. Currently in open source, only heap backend uses this path. I don't have a strong opinion though, if you think the delete strategy is safer, I can go with that



-- 
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-40339][table] Do not read buffer entries after removing them [flink]

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #28933:
URL: https://github.com/apache/flink/pull/28933#issuecomment-5202258551

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "d64a01a8876eaf0b3c8c52c39438892026e6bbc6",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "d64a01a8876eaf0b3c8c52c39438892026e6bbc6",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * d64a01a8876eaf0b3c8c52c39438892026e6bbc6 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-40339][table] Do not read buffer entries after removing them [flink]

Posted by "gustavodemorais (via GitHub)" <gi...@apache.org>.
gustavodemorais merged PR #28933:
URL: https://github.com/apache/flink/pull/28933


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