Repository navigation
fix(cascade): 限制批次内并发执行的 handler 数量 - #492
Merged
gloryfromca merged 2 commits intoOct 15, 2026
Merged
gloryfromca merged 2 commits into
gloryfromca merged 2 commits into
Conversation
This was referenced Oct 14, 2026
gloryfromca
approved these changes
Oct 15, 2026
The semaphore was built inside drain_once, so two concurrent drains each
got their own and the bound doubled. That overlap is the shipped path:
POST /cascade/quiesce calls drain_fully() before stop() while the
background loop is still draining, which CascadeOrchestrator.drain_fully
documents ("the background worker claims batches too"). A regression
test reproduces it -- peak 8 against a documented bound of 4.
Also pass handler_concurrency through from CascadeConfig. Nothing did,
so the default was hardcoded in production and the positive-value guard
was unreachable; every other worker knob already has a config field.
The existing assertion used <=, which a bound accidentally set to 1
would also satisfy; peak is deterministic here, so pin it with ==.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
gloryfromca
force-pushed
the
feature/cascade-worker-concurrency-bound
branch
from
October 15, 2026 09:08
b4ec080 to
05fb42d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
cascade worker 在单个批次内对 50 行并发执行 handler。daily-log handler 先按
md_path解析既有行,碎片化的 Lance 表上该查询是原生全量扫描:50 个并发 handler 曾把生产数据回放推到 8.29 GiB 且 80 秒内未完成;1/2/4/8 并发的峰值约 0.26/0.61/0.98/1.73 GiB。原生查询不受 Python 取消控制,超时后仍会成倍占用内存与文件句柄。改法
handler_concurrency(默认 4):领取批次仍为 50 行保持队列语义,仅限制同时执行的 handler 数量。验证
范围
仅含通用修复与测试。