- Notifications
You must be signed in to change notification settings - Fork13.8k
[FLINK-38349][runtime] Address SpillingThread Zero-Division During Channel Merging Operations#27238
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…ion Test to Avoid Reflective Calls
…nel Sizes Beyond Powers of maxFansIn
[FLINK-38349][runtime] Updated SpillingThreadTest Verbiage
… During Channel Merging Operations[FLINK-38349][runtime] Address Potential SpillingThread Zero-Division During Channel Merging Operations
flinkbot commentedNov 13, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
rionmonster commentedNov 13, 2025
@flinkbot run azure |
rionmonster commentedNov 13, 2025
First of all, hi! I’m tagging you because Most of the changes are in the tests—first to reproduce the issue, then to verify the fix. The actual fix for the floating-point bug ended up being quite small by comparison. Any feedback you have would be greatly appreciated! |
Uh oh!
There was an error while loading.Please reload this page.
What is the purpose of the change
This pull request addresses the issue detailed inFLINK-38349 which describes scenarios in which certain edge-case values for
maxFanInandchannelIDs.size()could result in floating-point errors that resulted in thrownArithmeticExceptionexceptions (specifically division by zero). This adds the appropriate safeguards to prevent these issues.The originating JIRA ticket provides detailed examples illustrating how the floating-point errors were reproduced. In summary,the issue occurs whenever the channel count (
channelIDs.size()) is greater than or equal to a power ofmaxFanIn:The overall change not only addresses the floating-point issues but alsoimproves scaling calculation performance by 3-4x on average (see chart below).
Brief change log
SpillingThread.mergeChannelList()by replacing the previousMath.log()-based calculations, which could result in floating point errors, in favor of an iterative, exponential search.computeMergeScaleForChannelSize()function to encapsulate and document the updated scaling calculations.SpillingThreadTestfile with an associated, parameterizedtestMergeChannelListDivideByZeroSafetytest that was used to reproduce the original issue and was later adjusted to confirm the fix.Verifying this change
This change added tests and can be verified as follows:
SpillingThreadTest.testMergeChannelListDivideByZeroSafetywhich originally reproduced the issue by creating a series of parameterized tests founds within the originating JIRA ticket.Verifying Performance
In addition to these tests related to reproduction, I performed a series of manual tests to verify performance between the previous
Math.log()-based approach (prone to floating-point error) and the newer iterative, exponential approach.You cansee the full gist here with all of the necessary code comparing the older and newer approaches (elected not to commit as it was purely for demonstration purposes).
Verifying Correctness
In addition to the above performance tests, I also performed a similar equivalence test comparing the generated results between the previous and new approaches to ensure parity (sans floating-point errors) for many of the common and edge case values presented earlier:
You can finda related gist containing these tests as well.
Does this pull request potentially affect one of the following parts:
@Public(Evolving):noDocumentation