Repository navigation
Commit ed467c5
[fix](be) Hold a zero adaptive scanner allocation on the TaskExecutor path
### What problem does this PR solve?
Issue Number: None
Related PR: #61271, #67070
Problem Summary:
`MemLimiter::available_scanner_count()` divides a scan node's memory budget, counted in blocks,
among its instances. When the budget holds fewer blocks than there are instances, the later
instances get zero: they may keep one task running, so that the scan still makes progress, and no
more. The thread-pool path holds them there (`can_admit_scan_task()`, since #67070). The
TaskExecutor path, the default for internal and external tables, did not:
`_pull_next_scan_task()` read `expected_scanners == 0` as `_max_scan_concurrency`, and
`_get_margin()` always asks for at least one task, so while the scheduler had slack every block the
operator consumed put its scanner straight back to work, and a scanner that finished was replaced
by a pending one.
While the adaptive concurrency stayed at its minimum of one, that made no difference. With the
previous commit an instance runs up to its memory ceiling; when the ceiling then falls to zero
(larger blocks, or another scan node of the query estimating larger ones), the instance kept every
scanner it held, up to `_max_scan_concurrency` (16 for file scans), for the rest of the scan, while
a ceiling of one drained to one.
`_pull_next_scan_task()` now takes `expected_scanners` as it is: `_get_margin()` refreshes it just
before, so zero is always an allocation, never a value not yet set. As in `can_admit_scan_task()`,
a task is still admitted when nothing is occupied, so a zero allocation cannot stall the scan.
### Release note
None
### Check List (For Author)
- Test: Unit Test
- `ScannerContextTest.task_executor_keeps_zero_adaptive_allocation` (new): on the TaskExecutor
path, an instance running two scanners whose allocation falls to zero puts the scanner whose
block was consumed back to pending while the other one is in flight, and still runs one
scanner once nothing is occupied. Without the change to `_pull_next_scan_task()` it fails:
the consumed scanner is resubmitted. All 44 `ScannerContextTest` pass (ASAN, macOS,
clang 22).
- Behavior changed: Yes. With `enable_adaptive_scan` on and the TaskExecutor scheduler, an instance
whose memory allocation falls to zero drains to one running scanner instead of keeping the ones
it had.
- Does this need documentation: No
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>1 parent 8784c4b commit ed467c5
2 files changed
Lines changed: 83 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
842 | | - | |
843 | | - | |
844 | | - | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
845 | 846 | | |
846 | 847 | | |
847 | | - | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
848 | 851 | | |
849 | 852 | | |
850 | 853 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
952 | 952 | | |
953 | 953 | | |
954 | 954 | | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
955 | 1031 | | |
956 | 1032 | | |
957 | 1033 | | |
| |||
0 commit comments