Fragile window abandonment during concatMap operations; silent data loss
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- java
调研方向
首先使用 Flowable.window() 配合 concatMapSingle() 和 concatMapMaybe() 运行两个复现,并比较 blockingSubscribe() 的不同变体。跟踪窗口放弃与下游订阅之间的交互;当窗口不会被静默丢弃,或放弃会产生文档中说明的错误时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Combining the Flowable.window() family of operators with any of the Flowable.concatMap*() operators appears to cause window abandonment bugs which are sensitive to how the outer Flowable is processed downstream. This despite the given concatMap lambdas returning an Rx Single/Maybe ready to be subscribed as soon as they are returned and which will signal the upstream window for subscription synchronously.
In the demonstrations below, I subscribe to identical .window().concatMap() constructions with very slightly different downstreams (.blockingSuscribe(System.out::println) vs. .doOnNext(System.out::println).blockingSubscribe()) and they emit drastically different results due to silent data-loss.
Example: Windowing a stream into lists, similar to the buffer() operator.
public static void main(String[] args) {
final var content = Flowable
.rangeLong(0, 100)
.window(10)
.concatMapSingle(Flowable::toList);
System.out.println("Example 1: Expected behavior for concetMapSingle(Flowable::toList)");
content
.doOnNext(System.out::println)
.blockingSubscribe();
System.out.println("Example 2: Window abandonment & data-loss");
content
.blockingSubscribe(System.out::println);
}
Output:
Example 1: Expected behavior for concetMapSingle(Flowable::toList)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
[20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
[30, 31, 32, 33, 34, 35, 36, 37, 38, 39]
[40, 41, 42, 43, 44, 45, 46, 47, 48, 49]
[50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
[60, 61, 62, 63, 64, 65, 66, 67, 68, 69]
[70, 71, 72, 73, 74, 75, 76, 77, 78, 79]
[80, 81, 82, 83, 84, 85, 86, 87, 88, 89]
[90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
Example 2: Window abandonment & data-loss
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[10]
[20]
[30]
[40]
[50]
[60]
[70]
[80]
[90]
Example: Windowing a stream into a simple reduction operation.
public static void main(String[] args) {
final var windowSums = Flowable
.rangeLong(0, 100)
.window(10)
.concatMapMaybe(window -> window.reduce(Long::sum));
System.out.println("Example 3: Expected behavior for concetMapMaybe(window -> window.reduce(Long::sum))");
windowSums
.doOnNext(System.out::println)
.blockingSubscribe();
System.out.println("Example 4: Silent data loss");
windowSums
.blockingSubscribe(System.out::println);
}
Output:
Example 3: Expected behavior for concetMapMaybe(window -> window.reduce(Long::sum))
45
145
245
345
445
545
645
745
845
945
Example 4: Silent data loss
45
10
20
30
40
50
60
70
80
90
The flatMap*() family of operators seem less prone to this behavior but don't guarantee to retain the upstream ordering.
Ideally, I'd expect window() to be compatible with concatMap(). But if such is impossible, I'd expect the window-abandonment detection described in https://github.com/ReactiveX/RxJava/wiki/What%27s-different-in-3.0#window-abandonment-in-window to at least signal an error.
- 主要语言
- Java
- 星标
- 48.2k
- 派生
- 7.6k
- 平均合并
- 3 小时 9 分钟
- 30 天内合并 PR
- 25
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ReactiveX/RxJava 的其他 Issue
-
4.x AI Enhancement Streamable
难度 4/5 3-5 天 新手友好度 45/100
ReactiveX/RxJava#8299 · 1 条评论 ·
维护者通常 1 天内回复
-
4.x: FlowableBufferTest > longTimeAction() FAILED可能重新可做 @akarnokd 于 74 天前认领,目前没有进行中的 PR。 未关闭4.x Test-Failures
ReactiveX/RxJava#8280 · 已指派 1 人 ·
维护者通常 1 天内回复
-
4.x Discussion
难度 5/5 一周以上 新手友好度 25/100
维护者通常 1 天内回复
-
4.x PR welcome Test Test-Failures
难度 4/5 3-5 天 新手友好度 45/100
ReactiveX/RxJava#8075 · 4 条评论 ·
维护者通常 1 天内回复
-
4.x: Cache/Replay operators to be more GC friendly可能重新可做 @DragonFSKY 于 87 天前认领,目前没有进行中的 PR。 未关闭4.x Enhancement
难度 4/5 3-5 天 新手友好度 45/100
ReactiveX/RxJava#7912 · 3 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
2026 Error Report
难度 2/5 1-3 小时 新手友好度 68/100
triplea-game/triplea#15096 ·
维护者通常 1 天内回复
-
[Bug][API] Switching workflow versions leaves schedules online可能已有人在做 @zhuangchong 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
apache/dolphinscheduler#18731 ·
维护者通常 1 天内回复
-
Implement JDBC Domain Enums (`SqlCategory`, `SqlExecutionStatus`, `SqlExecutionType`) in Core Module未关闭core-module enhancement good first issue
难度 1/5 1-3 小时 新手友好度 87/100
sdlc-pro/spring-lens#531 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
apache/rocketmq-dashboard#7340 ·
维护者通常 3 天内回复