drbothen opened a new pull request, #2144:
URL: https://github.com/apache/iceberg-rust/pull/2144

   ## Which issue does this PR close?
   
   N/A — standalone bug fix.
   
   ## What changes are included in this PR?
   
   The `update_totals` function in `snapshot_summary.rs` performs `new_total -= 
value` on a `u64`. When `removed > previous_total + added` (which can happen if 
metadata summaries are inconsistent or after certain compaction flows), this 
causes a subtraction overflow panic in debug mode and wraps to a massive number 
in release mode.
   
   This PR replaces the subtraction with `saturating_sub`, clamping the result 
to 0 instead.
   
   ## Are these changes tested?
   
   Yes — unit test `test_update_totals_saturating_sub_no_panic` covers the 
overflow scenario (removed=15, previous_total=10, added=1).


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to