Metrics refresh full-scans okapi_outbox (COUNT(*) GROUP BY status incl. 7 days of DELIVERED) every 15s per instance
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 1-2 天
- 新手友好度
- 42/100
- Issue 類型
- 重構
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- kotlin, mysql, postgresql
研究方向
Start in MicrometerOutboxMetrics, where the refresh runs the two queries, and in OutboxStore.countByStatuses and findOldestCreatedAt, which hold the GROUP BY status SQL. Decide which statuses the metrics need, then rewrite the oldest-per-status lookup as an index-ordered LIMIT 1 query per status. Done when the queries no longer scan DELIVERED rows and the metrics tests still pass on both PostgreSQL and MySQL.
由索引模型根據 Issue 內容生成。
描述
Severity: Medium (performance) · Area: okapi-micrometer MicrometerOutboxMetrics, OutboxStore.countByStatuses/findOldestCreatedAt · Found in: code review of main @ e5630a1
Problem
Every metrics refresh runs two queries per instance, every 15 s by default:
SELECT status, COUNT(*) FROM okapi_outbox GROUP BY status;
SELECT status, MIN(created_at) FROM okapi_outbox WHERE status IN (?,?,?) GROUP BY status;
COUNT(*) ... GROUP BY statushas to visit every row. The table keeps 7 days ofDELIVEREDrows by default (purger retention), which is ~60 M rows at 100 msg/s. N application instances each run this full scan every 15 s.- The
MIN(created_at)query is index-friendly on MySQL (loose index scan), but Postgres before v18 has no skip scan.GROUP BY statuswithINcan scan the whole(status, created_at)index, again dominated byDELIVEREDrows nobody alerts on.
Load grows with retention × throughput × instance count, on the same primary that serves the application's writes.
Suggested fix
- Restrict both queries to the statuses that matter operationally (
PENDING,FAILED).DELIVEREDcount/lag is rarely useful, and when it is, it can come from the counters. - Compute oldest-per-status with per-status index-ordered lookups, e.g.
(SELECT created_at FROM okapi_outbox WHERE status='PENDING' ORDER BY created_at LIMIT 1), which costs O(log n) on both databases. - Optionally report
DELIVEREDfrom planner estimates or drop it.
- 主要語言
- Kotlin
- 星號
- 14
- 分支
- 0
- 平均合併
- 9 小時 54 分鐘
- 30 天內合併 PR
- 11
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
softwaremill/okapi 的其他 Issue
-
bug
難度 5/5 一週以上 新手友好度 35/100
softwaremill/okapi#141 ·
維護者通常 1 天內回覆
-
OutboxProcessorListener events are emitted before the transaction commits; metrics over-count on commit failure可能已有人在做 @rawo 今天認領。 未關閉breaking-change bug
難度 4/5 3-5 天 新手友好度 35/100
softwaremill/okapi#137 ·
維護者通常 1 天內回覆
-
breaking-change bug
難度 4/5 3-5 天 新手友好度 35/100
softwaremill/okapi#135 ·
維護者通常 1 天內回覆
-
bug
難度 3/5 半天 新手友好度 62/100
softwaremill/okapi#134 ·
維護者通常 1 天內回覆
-
enhancement
難度 5/5 一週以上 新手友好度 22/100
softwaremill/okapi#133 ·
維護者通常 1 天內回覆
查看 softwaremill/okapi 的全部 Issue
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 65/100
Droid-Deck/DroidDeck#2198 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 77/100
world-federation-of-advertisers/cross-media-measurement#4846 ·
維護者通常 1 天內回覆
-
autoteam community connectors/destination/mssql connectors/source/hubspot team/use
難度 2/5 1-3 小時 新手友好度 77/100
airbytehq/airbyte#91201 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug javascript
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
Source: c7 Type: bug
難度 2/5 1-3 小時 新手友好度 72/100