refactor(ingress): 移除 G1 窗口补偿扫描与迟到到达检测

实际负载不足 10 条/秒,G1 属过度防御。删除迟到到达检测机制、
existingIds 接口、PipelineCounters 字段、lateDetect 配置,
以及文档中 CLM-1/CLM-2 声明与 G1 缺口索引。
This commit is contained in:
windyboy
2026-09-13 08:08:43 +08:00
parent a6b2120836
commit b8738554e6
20 changed files with 10 additions and 322 deletions
@@ -1,7 +1,6 @@
package com.gzzn.omms.msgexchange.infra.metrics
import jakarta.inject.Singleton
import java.util.concurrent.atomic.AtomicLong
/**
* 管道运行期的**进程内**计数。
@@ -12,26 +11,4 @@ import java.util.concurrent.atomic.AtomicLong
* 注意:计数在重启后归零。需要跨重启的累计值应由指标后端聚合,不在这里做持久化。
*/
@Singleton
class PipelineCounters {
private val holeAgedOut = AtomicLong(0)
private val lateArrivalDetected = AtomicLong(0)
/** 水位因空洞超过老化阈值而放行(判定为永久空洞)的次数。 */
fun holeAgedOutIncrement() {
holeAgedOut.incrementAndGet()
}
fun holeAgedOutCount(): Long = holeAgedOut.get()
/**
* "迟到到达"检测命中的**不同**消息 ID 数(ACM2-41 阶段 0)。
*
* 含义:该 ID 曾被判定为永久空洞并放行,之后却真的出现在信箱里——即上游提交晚于水位推进。
* 阶段 0 只计数与告警,**不会**补入队;因此这个值 > 0 表示"确有迟到发生,需要与库方对契约"。
*/
fun lateArrivalDetectedIncrement() {
lateArrivalDetected.incrementAndGet()
}
fun lateArrivalDetectedCount(): Long = lateArrivalDetected.get()
}
class PipelineCounters
@@ -22,7 +22,6 @@ import java.time.Duration
* - `msgx.pipeline.backfill.abandoned`:已放弃自动回填的条数(**非 0 需人工对账**)
* - `msgx.pipeline.backfill.oldest_unmarked_seconds`:最老一条仍待自动回填的年龄
* - `msgx.pipeline.watermark.lag`:水位落后信箱最新 ID 的距离
* - `msgx.pipeline.hole.aged_out.total`:永久空洞放行次数
* - `msgx.pipeline.job.heartbeat_age_seconds`:距上一次作业 tick 完成的秒数(未跑过为 -1)
* - `msgx.pipeline.job.last_failure_age_seconds`:距最近一次作业 tick 失败的秒数(从未失败为 -1)
* - `msgx.pipeline.job.ticks.total` / `msgx.pipeline.job.failures.total`:作业 tick 完成/抛错次数
@@ -44,7 +43,6 @@ class PipelineMetrics(
private val backlogs: BacklogSnapshotProvider,
private val cursor: BeanProvider<InboxCursorRepository>,
private val mailbox: BeanProvider<CminmsgInboxRepository>,
private val counters: PipelineCounters,
private val activity: JobActivity,
private val clock: Clock,
) {
@@ -71,15 +69,6 @@ class PipelineMetrics(
if (watermark != null && maxId != null) (maxId - watermark).toDouble() else -1.0
}.strongReference(true).register(registry)
Gauge.builder("msgx.pipeline.hole.aged_out.total", counters) { it.holeAgedOutCount().toDouble() }
.strongReference(true)
.register(registry)
// 迟到到达检测命中数(阶段 0 只观测):> 0 表示上游提交确实晚于水位推进,需要与库方对契约。
Gauge.builder("msgx.pipeline.late_arrival.detected.total", counters) { it.lateArrivalDetectedCount().toDouble() }
.strongReference(true)
.register(registry)
// 作业心跳与扫描积压:作业线程是回填的唯一驱动,停摆必须能被 /metrics 与 /health 看见。
Gauge.builder("msgx.pipeline.job.heartbeat_age_seconds", activity) { a ->
a.snapshot().lastTickAt?.let { Duration.between(it, clock.instant()).seconds.toDouble() } ?: -1.0