UsageManagerImpl.parse() rewind to the oldest unprocessed usage event is unbounded
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
调研方向
从 UsageManagerImpl.parse() 和 UsageEventDaoImpl.listLatestEvents() 开始,然后检查 issue 中描述的 usage_job 和 usage_event 查询。复现固定的 start_date 和不断增长的聚合范围,并定义有界回溯或事件隔离行为,其完成标准包括防止一个永久未处理的事件导致无限制的重新聚合。
由索引模型根据 Issue 内容生成。
描述
problem
Split out of #13399 at @DaanHoogland's request.
UsageManagerImpl.parse() correctly derives its start date from the last successful job:
long lastSuccess = _usageJobDao.getLastJobSuccessDateMillis();
if (lastSuccess != 0) {
startDateMillis = lastSuccess + 1;
}
and then overwrites it with the create date of the oldest unprocessed event, moving it only ever earlier:
// make sure start date is before all of our un-processed events
Date oldestEventDate = events.get(0).getCreateDate();
if (oldestEventDate.getTime() < startDateMillis) {
startDateMillis = oldestEventDate.getTime();
startDate = new Date(startDateMillis);
}
events comes from UsageEventDaoImpl.listLatestEvents() — WHERE processed = 0 AND created <= ? ORDER BY createDate ASC, with no limit and no floor.
Consequence: any event that can never be successfully processed pins the aggregation start date permanently. Each subsequent run re-aggregates from that date to the present, growing by one aggregation range per range elapsed. The job continues to report success = 1 throughout, so nothing surfaces as an error.
Measured on an affected 4.22.1.0 deployment:
- 1,678 consecutive successful jobs whose
start_millisnever advanced past a single event 71 days earlier exec_timeof 2,555,055 ms (42.6 min) per hourly run, growing by 24 aggregation periods per daycloud_usageat 54.4M rows / 14 GB, of which roughly 150k rows were genuine; duplicate counts were an exact multiple of the number of replays
Not specific to one event type: #13112 was reported on 4.21.0.0 against usage_type = 13, predating the volume-specific trigger in #13399. The rewind is the common mechanism; the triggering event type varies.
versions
Observed on CloudStack 4.22.1.0 (EL9 packages), MySQL 8.x / InnoDB, with usage.stats.job.aggregation.range = 60 and usage.stats.job.exec.time = 00:15.
#13112 reports the same mechanism on 4.21.0.0, so this is not new in 4.22.
The steps to reproduce the bug
- Have any row in
cloud_usage.usage_eventthat cannot be successfully processed, #13399 gives one reliable route, but the mechanism is independent of cause. - Let the usage job run on its normal schedule.
SELECT id, start_date, end_date, exec_time FROM cloud_usage.usage_job WHERE success = 1 ORDER BY id DESC LIMIT 5;—start_datestays pinned at the oldest unprocessed event'screatedwhileend_dateadvances.TIMESTAMPDIFF(HOUR, start_date, end_date)grows without bound, as doesexec_time.- Row counts in
cloud_usage.cloud_usageper period equal the number of times that period has been re-aggregated.
What to do about it?
Bound the rewind, and/or provide a way to quarantine or age out events that repeatedly fail to process, so one unprocessable row cannot halt aggregation indefinitely.
This is a design decision rather than an obvious patch, which is why it's raised separately from #13399.
- 主要语言
- Java
- 星标
- 3.1k
- 派生
- 1.4k
- 平均合并
- 6 天 20 小时
- 30 天内合并 PR
- 27
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/cloudstack 的其他 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
bug component:kubernetes
难度 1/5 1 小时以内 新手友好度 88/100
apache/cloudstack#14180 ·
-
bug component:projects component:UI
难度 1/5 1 小时以内 新手友好度 88/100
apache/cloudstack#14070 · 5 条评论 ·
-
component:backup
难度 2/5 1-3 小时 新手友好度 76/100
apache/cloudstack#14013 ·
-
KVM agent fails to connect to Ceph RBD storage pool after upgrading Ceph client to Tentacle 20.2.4 未关闭bug component:ceph
难度 2/5 1-3 小时 新手友好度 78/100
apache/cloudstack#13989 · 3 条评论 ·
查看 apache/cloudstack 的全部 Issue
相似的 Issue
-
certification
难度 1/5 1 小时以内 新手友好度 80/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's 未关闭bug ecr
难度 2/5 1-3 小时 新手友好度 75/100
-
Needs: Triage Type: Feature request
难度 2/5 1-3 小时 新手友好度 70/100
AntennaPod/AntennaPod#8794 ·
-
agentic-workflows
难度 2/5 1-3 小时 新手友好度 65/100
github/copilot-sdk#2760 ·