Delivery I/O runs inside the claim transaction: pool starvation, idle-in-transaction kills cause infinite redelivery, MVCC bloat
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 22/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- kafka, kotlin, mysql, postgresql
研究方向
Start with the KDoc on CompositeMessageDeliverer, which acknowledges the open transaction, and trace where the claim, delivery and status update share one transaction. Check the hard-coded CONNECT_TIMEOUT and REQUEST_TIMEOUT and the concurrency setting against the pool size. Done means the maintainers have agreed on the lease-based claim design or the startup guard, with tests covering a delivery that outlives the server's idle timeout.
由索引模型根據 Issue 內容生成。
描述
Severity: Medium-High (pool starvation, duplicate-delivery loop, DB bloat) · Area: processor transaction design · Found in: code review of main @ e5630a1
Problem
The whole cycle (claim with FOR UPDATE SKIP LOCKED → network delivery → status update) runs in one DB transaction, so a pooled connection sits idle in transaction for as long as the transport I/O takes:
- HTTP: up to 10 s connect + 30 s request timeout (hard-coded
CONNECT_TIMEOUT/REQUEST_TIMEOUT, not configurable) - Kafka:
producer.flush()blocks up todelivery.timeout.ms(120 s default)
Concrete failure modes:
- Connection-pool starvation.
concurrencyaccepts values up to 256, and each worker holds one connection for the full delivery. Nothing checks this against the pool size: Hikari's default is 10. Withconcurrency >= pool sizeand a slow downstream, okapi takes every connection and the application's own requests time out ongetConnection(). - Infinite duplicate loop under server-side timeouts. With Postgres
idle_in_transaction_session_timeout, or a MySQLwait_timeout/proxy idle timeout shorter than the delivery time, the server kills the session mid-delivery. The final update/commit fails, and every entry that was actually delivered reverts toPENDINGwithretriesunchanged. It is delivered again on the next tick, killed again, and so on for as long as the downstream stays slow.retriesnever advances, so nothing ever reachesFAILED. - MVCC bloat (Postgres). Long transactions hold back the xmin horizon on what is by design a very high-churn table (every row is inserted, then updated, then deleted), which degrades vacuum for the entire database.
- Combined with the MySQL gap-lock issue, publishers are blocked for the same duration.
The KDoc on CompositeMessageDeliverer acknowledges the open transaction, but the consequences above aren't documented or guarded against.
Suggested fix
- Preferred: a lease-based claim. In a short transaction, mark rows
PROCESSINGwithlocked_until = now + leaseTimeout(or bump aclaim_token), commit, deliver outside any transaction, then write results in a second short transaction guarded by the claim token. A reaper (or the claim query itself) reclaims rows whose lease has expired. - At minimum: fail fast or warn at startup when
concurrency≥ the pool's maximum size; make the HTTP timeouts configurable; document the required relationship between delivery timeouts andidle_in_transaction_session_timeout/lock-wait timeouts.
- 主要語言
- Kotlin
- 星號
- 14
- 分支
- 0
- 平均合併
- 14 小時 16 分鐘
- 30 天內合併 PR
- 9
環境準備
這個專案沒有提供開發容器、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 於 2 天前認領。 未關閉breaking-change bug
難度 4/5 3-5 天 新手友好度 35/100
softwaremill/okapi#137 ·
維護者通常 1 天內回覆
-
enhancement
難度 4/5 1-2 天 新手友好度 42/100
softwaremill/okapi#136 ·
維護者通常 1 天內回覆
-
bug
難度 3/5 半天 新手友好度 62/100
softwaremill/okapi#134 ·
維護者通常 1 天內回覆
-
bug critical
難度 3/5 1-2 天 新手友好度 52/100
softwaremill/okapi#132 ·
維護者通常 1 天內回覆
查看 softwaremill/okapi 的全部 Issue
相似的 Issue
-
submit-adaption submit-adaption-pre
難度 1/5 1 小時以內 新手友好度 72/100
BetterAndroid/android-notification-icon-project#848 · 1 則留言 ·
維護者通常 1 天內回覆
-
bug
難度 1/5 1-3 小時 新手友好度 70/100
orgzly-revived/orgzly-android-revived#1132 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
commons-app/apps-android-commons#7275 ·
維護者通常 1 天內回覆
-
documentation
難度 2/5 1-3 小時 新手友好度 78/100
liberation-data/drivine4j#682 ·
維護者通常 1 天內回覆
-
documentation good first issue
難度 2/5 1-3 小時 新手友好度 78/100
developmentwithyash/yaan#14 ·
維護者通常 2 天內回覆