cherry-pick #41668
fix scan range boundary handling is incorrect Co-authored-by: shizhiqiang03 <shizhiqiang03@meituan.com>