aw-sync: events at a page boundary are synced with duration 0 (clipped re-fetch), permanently
维护者通常 1 天内回复
评估
调研方向
Start in aw-sync/src/sync.rs at sync_one (around lines 1215–1245), where the page boundary run is dropped and re-fetched with fetch_end = Some(boundary_ts), then compare with the cut - 1ns workaround in dedupe.rs. Run the repro test in boundary_dedup_multipage_tests first; it fails with left 100, right 120. Done means that test passes, every boundary event keeps its duration, and the existing multipage tests still pass. Either re-fetch the boundary run with get_events_unclipped or page with end = boundary_ts - 1ns.
由索引模型根据 Issue 内容生成。
描述
When sync_one (aw-sync/src/sync.rs ~1215–1245) gets a full page, it drops the run of events at the page's oldest timestamp (boundary_ts) and re-fetches it on the next page with fetch_end = Some(boundary_ts). But get_events clips results to the query end (parse_event_row). Every event that starts at boundary_ts therefore comes back as (boundary_ts, duration 0) and is inserted into the destination that way.
dedupe.rs already documents this clipping and works around it with cut - 1ns. sync_one does not.
Effect: on any pass that copies more than one page (5000 events) of a bucket, one event per page boundary lands with duration 0. That includes every first sync of a real bucket and catch-up after time offline. Later passes don't repair it, because the (timestamp, duration) identity no longer matches. The loss is silent and permanent, and on AFK buckets a single event can be hours long. It affects pull (peer → local) and push (local → staging → every peer).
Repro: add this test to boundary_dedup_multipage_tests in aw-sync/src/sync.rs, where BATCH_SIZE is small. It fails on master ea6f09c with left: 100, right: 120, and the boundary events come back at 0 s.
#[test]
fn page_boundary_event_keeps_its_duration() {
let ds_src = Datastore::new_in_memory(false);
let ds_dest = Datastore::new_in_memory(false);
let bucket: Bucket = serde_json::from_value(serde_json::json!({
"id": "bucket-0", "type": "test", "hostname": "device-0", "client": "test"
})).unwrap();
ds_src.create_bucket(&bucket).unwrap();
let base_ts: DateTime<Utc> = Utc::now() - Duration::hours(1);
let events: Vec<Event> = (0..12).map(|i| serde_json::from_value(serde_json::json!({
"timestamp": (base_ts + Duration::seconds(i * 10)).to_rfc3339(),
"duration": 10.0,
"data": {"title": format!("w{i}")}
})).unwrap()).collect();
ds_src.insert_events("bucket-0", &events).unwrap();
ds_src.force_commit().unwrap();
sync_datastores(&ds_src, &ds_dest, false, None, &SyncSpec::default()).unwrap();
let got = ds_dest.get_events("bucket-0-synced-from-device-0", None, None, None).unwrap();
let total: i64 = got.iter().map(|e| e.duration.num_seconds()).sum();
assert_eq!(got.len(), 12);
assert_eq!(total, 120, "every event must keep its duration across page boundaries");
}
The existing multipage tests check counts and duplicates, not durations, which is why they pass.
Suggested fix: re-fetch the boundary run unclipped (get_events_unclipped already exists on the datastore), or page with end = boundary_ts - 1ns and keep the boundary run whole, as dedupe.rs does. #789 keeps this timestamp path for push and its fallback, so it does not fix this.
- 主要语言
- Rust
- 星标
- 322
- 派生
- 107
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 25
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ActivityWatch/aw-server-rust 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
ActivityWatch/aw-server-rust#883 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
ActivityWatch/aw-server-rust#872 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
ActivityWatch/aw-server-rust#798 · 1 条评论 ·
维护者通常 1 天内回复
-
query: categorize rules can pin unbounded memory in the regex cache and run past query_timeout可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 22/100
ActivityWatch/aw-server-rust#893 · 1 条评论 ·
维护者通常 1 天内回复
-
aw-client CLI ignores aw-client.toml host/port可能已有人在做 @TimeToBuildBob 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
ActivityWatch/aw-server-rust#888 ·
维护者通常 1 天内回复
查看 ActivityWatch/aw-server-rust 的全部 Issue
相似的 Issue
-
area: cli good first issue type: feature
难度 2/5 1-3 小时 新手友好度 78/100
-
[Bug] Windows Ghidra provider rejects a PATH-only JDK: bare `java.exe` probe fails with Win32 87未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
renaming a provider to a taken name fails with a raw sql error可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area:storage kind:bug priority:p3 ready
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
bug bugfix
难度 2/5 1-3 小时 新手友好度 72/100
storytold/photocraft#16975 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复