[Bug] BE division-by-zero error occurs when calculating inode_percentage
- Dominant language
- Java
- Stars
- 15.9k
- Forks
- 3.9k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 520
Description
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.
### Version
4.1 7126cf65d96ebc43fce0906f51e92c1a2ccf24a6 cloud version
### What's Wrong?
In some environment, the inode statistics f_files/f_ffree are 0, which causes a BE division-by-zero error.
inode_total = stat.f_files = 0
inode_free = stat.f_ffree = 0
```
Thread 185 "run_background_" received signal SIGFPE, Arithmetic exception.
0x000055556bce32e8 in doris::io::disk_used_percentage (path=..., percent=0x7fff109ead50) at /home/chen/Programming/doris-4.1/be/src/io/cache/block_file_cache.cpp:1822
1822 int inode_percentage = cast_set(inode_free * 100 / inode_total);
(gdb) bt
#0 0x000055556bce32e8 in doris::io::disk_used_percentage (path=..., percent=0x7fff109ead50) at /home/chen/Programming/doris-4.1/be/src/io/cache/block_file_cache.cpp:1822
#1 0x000055556bce422a in doris::io::BlockFileCache::check_disk_resource_limit (this=0x7fff151c6000) at /home/chen/Programming/doris-4.1/be/src/io/cache/block_file_cache.cpp:1901
#2 0x000055556bce564d in doris::io::BlockFileCache::run_background_monitor (this=0x7fff151c6000) at /home/chen/Programming/doris-4.1/be/src/io/cache/block_file_cache.cpp:1998
#3 0x000055556bd313c3 in std::__invoke_impl (
__f=@0x7fff14da6ff0: (void (doris::io::BlockFileCache::*)(doris::io::BlockFileCache * const)) 0x55556bce54b4 , __t=@0x7fff14da6fe8: 0x7fff151c6000)
at /home/chen/Programming/doris-4.1/ldb_toolchain/lib/gcc/x86_64-pc-linux-gnu/15/include/g++-v15/bits/invoke.h:76
#4 0x000055556bd31228 in std::__invoke (
__fn=@0x7fff14da6ff0: (void (doris::io::BlockFileCache::*)(doris::io::BlockFileCache * const)) 0x55556bce54b4 )
at /home/chen/Programming/doris-4.1/ldb_toolchain/lib/gcc/x86_64-pc-linux-gnu/15/include/g++-v15/bits/invoke.h:98
#5 0x000055556bd30a99 in std::thread::_Invoker >::_M_invoke<0ul, 1ul> (this=0x7fff14da6fe8)
at /home/chen/Programming/doris-4.1/ldb_toolchain/lib/gcc/x86_64-pc-linux-gnu/15/include/g++-v15/bits/std_thread.h:303
#6 0x000055556bd3078c in std::thread::_Invoker >::operator() (this=0x7fff14da6fe8)
at /home/chen/Programming/doris-4.1/ldb_toolchain/lib/gcc/x86_64-pc-linux-gnu/15/include/g++-v15/bits/std_thread.h:310
#7 0x000055556bd30222 in std::thread::_State_impl > >::_M_run (this=0x7fff14da6fe0)
at /home/chen/Programming/doris-4.1/ldb_toolchain/lib/gcc/x86_64-pc-linux-gnu/15/include/g++-v15/bits/std_thread.h:255
#8 0x000055557c6bc014 in execute_native_thread_routine ()
#9 0x00007ffff6962d19 in start_thread () from /lib64/libc.so.6
#10 0x00007ffff69e664c in __clone3 () from /lib64/libc.so.6
(gdb) p stat
$5 = {f_type = 2435016766, f_bsize = 4096, f_blocks = 124348672, f_bfree = 83618897, f_bavail = 83530293, f_files = 0, f_ffree = 0, f_fsid = {__val = {-1491911987, -353343286}}, f_namelen = 255, f_frsize = 4096,
f_flags = 4128, f_spare = {0, 0, 0, 0}}
(gdb) p inode_free
$6 = 0
(gdb) p inode_total
$7 = 0
```
file system infos:
```
$ df -T /home/chen/Programming/doris-4.1/output/be/file_cache
文件系统 类型 1K的块 已用 可用 已用% 挂载点
/dev/nvme0n1p3 btrfs 497394688 163018220 334023188 33% /home
```
### What You Expected?
not coredump
### How to Reproduce?
_No response_
### Anything Else?
_No response_
### Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
Contributor guide
Research direction
Start in be/src/io/cache/block_file_cache.cpp at doris::io::disk_used_percentage, especially line 1822 and its caller BlockFileCache::check_disk_resource_limit. Reproduce or inspect the f_files and f_ffree handling for filesystems that report zero inode counts. Done means the background monitor no longer raises a division-by-zero error in that environment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100