Heap growth during stream reconnects, stale-cache retention, and SDK lifecycle defects
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 18/100
- Issue 類型
- 缺陷
- 描述清晰度
- 需要釐清
- 活躍度
- 活躍
- 技術堆疊
- java
- 領域
- backend, performance
研究方向
The report bundles several separate defects, so pick one reproduction rather than the whole issue. The stale-cache case starts at the full-refresh upsert path in the repository; the XML case starts at StorageRepository backed by XmlFileMapStore, where Properties rejects non-string values. Run the synthetic 100-flag, 20-segment test to confirm the retained counts before changing anything. Done means one reproduction now passes with a matching test, and the issue is split so the production memory question is tracked separately.
由索引模型根據 Issue 內容生成。
描述
We investigated memory growth in a production Java service using the Harness Feature Flags SDK through a relay proxy. Stream disconnects and HTTP 503 retries coincided with increases in old-generation heap usage.
Separately, controlled tests against official SDK 1.9.3 reproduced stale-cache retention and several other defects. We have not established that these defects caused the production memory growth.
Production observations come from application and relay logs plus JVM metrics. Controlled SDK reproductions use official version 1.9.3. Service and infrastructure identifiers below are anonymized.
Production timeline
On 6 November 2026, both replicas of service-a lost their stream connections almost simultaneously. All times below are WIB, UTC+7.
| Time | Observed event |
|---|---|
| 07:36:34.735 | Relay writer logs that its upstream Harness SSE stream disconnected. |
| 07:36:35.052 | Relay writer publishes DISCONNECTED to its read replicas. |
| 07:36:35.071–07:36:35.078 | Both application pods report SSE stream disconnected, reason: End of SSE stream. |
| 07:36:35.413 | Pod B receives its first HTTP 503 from the relay stream endpoint. Polling has started with a 60-second interval. |
| 07:36:38.867 | Relay writer logs HTTP/2 GOAWAY, ErrCode=NO_ERROR, debug="max_age", with a 60-second retry delay. |
| 07:36:45.193–07:37:34.020 | Pod B records three more HTTP 503 responses. Its four retry delays are approximately 9.76, 19.52, 29.28, and 39.04 seconds. |
| 07:37:42.875 | Relay writer reconnects upstream and publishes the connected state. |
| 07:38:09.497 | Pod A reconnects. |
| 07:38:13.070 | Pod B reconnects successfully after five attempts. |
The relay’s upstream disconnection lasted approximately 68 seconds. Application stream recovery took approximately 94–98 seconds.
The logs identify the relay interruption and subsequent retries. They do not identify which upstream component initiated the connection-age termination.
Memory around this event
Old-generation heap usage increased across the same interval:
| JVM | 07:34 WIB | 07:40 WIB | Increase |
|---|---|---|---|
| Pod A | 294.35 MiB | 396.01 MiB | 101.66 MiB |
| Pod B | 260.29 MiB | 340.46 MiB | 80.17 MiB |
These are per-JVM sampled metrics, not deployment totals or matched post-GC measurements. The saved range metrics use five-minute maxima, so they show the surrounding increase rather than its exact allocation time.
From 5 November at 19:00 WIB to 6 November at 10:00 WIB, Pod B’s container working set increased from 527.07 MiB to 848.04 MiB. Its committed Java heap increased from 133.5 MiB to 412.5 MiB. Committed heap and container working set are different measurements and should not be added together.
Similar shared stream disconnects occurred on:
- 5 November, 22:42:17 WIB: both pods reconnected by 22:42:48.
- 6 November, 01:53:50 WIB: both pods reconnected by 01:55:20.
- 6 November, 04:00:42 WIB: both pods disconnected and reconnected within the same second.
There is also evidence against interpreting all of this growth as retained live objects. On 5 November, between the 20:20 and 20:25 WIB samples, a natural major GC reduced Pod A’s old-generation usage from 377.57 MiB to 54.68 MiB, without a process restart. No further major GC appeared in the saved counters through 6 November at 10:00 WIB.
The production data therefore establishes a time correlation between reconnect activity and heap growth. It does not distinguish temporary refresh allocations from a retention defect.
Controlled reproduction: missed deletions survive reconnect
The following separate test reproduces stale-cache retention in official SDK 1.9.3, using synthetic data and a local HTTP/SSE server:
- Initialize a streaming client with 100 flags and 20 segments, each containing 1,000 synthetic target entries.
- Disconnect the stream.
- Replace 99 flag identifiers and all 20 segment identifiers on the server.
- Reconnect without delivering the deleted objects’ stream events.
- Return complete lists containing only the current flags and segments.
- Repeat and inspect repository contents and heap usage after full GC.
Expected: a successful complete refresh leaves 100 flags and 20 segments.
Actual: full refreshes upsert returned objects but retain absent identifiers. After 10 cycles, the SDK retained 1,090 flags and 220 segments. Post-GC used heap increased from 10.73 MiB to 45.12 MiB.
The default cache has an entry limit. This demonstrates stale retention and additional heap usage, not an unlimited entry count. Missed deletions have not been established in the production incident above.
Additional findings reproduced on SDK 1.9.3
| Area | Reproduction and observed behavior |
|---|---|
| Retry cancellation | Stop a stream while its request receives HTTP 503 responses. The interceptor continues retrying the canceled call and retains its worker. Later attempts can fail locally without reaching the relay. |
| Segment membership | Segment entry customer-12345 incorrectly matches target 123. Both inclusion and exclusion checks use substring matching. |
| Stream ordering | Block a version 2 patch fetch, process a version 3 delete, then release the fetch. The older patch restores the deleted flag. |
| Analytics retention | Three successful batches of 40,000 distinct targets leave 120,000 target objects in static history after close. |
| Analytics delivery | A failed upload still marks target metadata as delivered. One client’s history can also suppress another client’s metadata. |
| Response cleanup | Malformed SSE data triggers the disconnect callback without closing the tracked response body. This does not establish a permanent socket leak in every reconnect path. |
| XML persistence | Store a FeatureConfig through StorageRepository backed by XmlFileMapStore, then close it. Serialization throws ClassCastException because Properties requires string values. |
| Shutdown | An in-flight poll can write after storage closes. Separately, a storage-close exception prevents subsequent connector cleanup. |
| Queue capacity | With update fetches blocked, 500 further messages remain queued in an effectively unbounded executor queue. This is a backlog capacity risk, not a demonstrated OOM. |
The analytics findings require analytics to be enabled. The XML finding concerns the optional XML store.
These controlled reproductions use synthetic identifiers, mocked connectors, or a loopback HTTP server. They establish specific SDK behaviors independently of the production memory observations.
- 主要語言
- Java
- 星號
- 6
- 分支
- 22
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
harness/ff-java-server-sdk 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 25/100
harness/ff-java-server-sdk#215 · 1 則留言 ·
-
難度 3/5 1-2 天 新手友好度 30/100
harness/ff-java-server-sdk#212 ·
-
難度 3/5 1-2 天 新手友好度 35/100
harness/ff-java-server-sdk#142 ·
查看 harness/ff-java-server-sdk 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
NucleusFramework/Nucleus#1020 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 83/100
ajeetraina/awesome-docker-sbx#839 ·
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
portfolio-performance/portfolio#6459 ·
維護者通常 2 天內回覆
-
Bug
難度 2/5 1-3 小時 新手友好度 75/100
bufbuild/protovalidate-java#564 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 83/100
it-at-m/traegerportal#17 ·