fix(delivery): claimBatch 排除已暂停 FLID,避免投递饿死(ACM2-95)
同 FLID 事件占满 delivery-batch 时后续轮次不再重复领到同一批;补饥饿回归用例。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -247,6 +247,34 @@ class DispatcherTickTest {
|
||||
assertTrue(f1Rows.all { it.state == EventStatus.PENDING })
|
||||
}
|
||||
|
||||
/** 暂停 FLID 事件数 ≥ delivery-batch 时,领批排除已暂停键,其他航班同轮仍可发(ACM2-95)。 */
|
||||
@Test
|
||||
fun `paused FLID filling the claim batch does not starve other flights`() {
|
||||
val repo = StubMsgEvents()
|
||||
val port = FailingMsgKeyPort("F1")
|
||||
val props = PipelineProps().apply {
|
||||
pipeline.deliveryBatch = 3
|
||||
pipeline.deliveryDrainRounds = 5
|
||||
schd.flushPeriod = java.time.Duration.ofHours(1)
|
||||
}
|
||||
val d = dispatcher(repo, port, props)
|
||||
// F1 三条占满 batch=3;F2 一条排在后面——旧实现会整轮领到同一批 F1 并 sent=0
|
||||
repo.insertAll(
|
||||
listOf(
|
||||
ev(1, Targets.KAFKA_MSG, "F1", """{"flid":"F1","v":1}"""),
|
||||
ev(2, Targets.KAFKA_MSG, "F1", """{"flid":"F1","v":2}"""),
|
||||
ev(3, Targets.KAFKA_MSG, "F1", """{"flid":"F1","v":3}"""),
|
||||
ev(4, Targets.KAFKA_MSG, "F2", """{"flid":"F2","v":1}"""),
|
||||
),
|
||||
)
|
||||
|
||||
d.tick()
|
||||
|
||||
assertEquals(1, port.sent.count { it.topic == "msg" && it.key == "F2" })
|
||||
assertEquals(0, port.sent.count { it.topic == "msg" && it.key == "F1" })
|
||||
assertTrue(repo.rows.values.filter { it.partitionKey == "F1" }.all { it.state == EventStatus.PENDING })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `msg head backoff not yet due pauses only the same FLID`() {
|
||||
val repo = StubMsgEvents()
|
||||
|
||||
Reference in New Issue
Block a user