Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

aw-sync: stale-row deletion uses timestamp identity, not tuple identity

Đang mở Phù hợp với người mới
#798 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu từ sync_one và kiểm tra vòng lặp phát hiện hàng cũ trong đường dẫn nhanh rowid, đặc biệt là ts_set.contains và bước kiểm tra dữ liệu không khớp được mô tả trong issue. Cập nhật quyết định về hàng cũ để sử dụng danh tính đầy đủ (timestamp, duration, data), sau đó chạy các bài kiểm thử sync liên quan; hoàn tất khi các hàng thay thế cũ vẫn bị xóa, nhưng một sự kiện nguồn có cùng timestamp với dữ liệu khác được giữ lại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

In the rowid fast path (sync_one), the stale-row detection loop deletes a dest event when:

  • a chunk event exists at the same timestamp AND
  • the dest event's data differs from the chunk event's data

This is correct for heartbeat watchers (fragments never share an exact ns-precision timestamp), but is wrong if two distinct source events happen to share a timestamp. The later source event arriving in the chunk would cause deletion of the earlier dest copy, and the original cannot be restored once the rowid cursor advances past it.

In practice this case does not occur in any current AW watcher (window, afk, web, app — all emit one event per state change). The risk is low, but the fix is straightforward: compare by (timestamp, duration, data) tuple rather than timestamp alone, and only mark a dest row stale if NO source event in the chunk matches its tuple identity.

Discovered via Greptile review of ActivityWatch/aw-server-rust#789 (r4205696158). The P1 "Backfills erase overlapping activity" was fixed in that PR (commit a7ac796); this is the remaining narrow case.

Fix: In sync_one, replace the ts_set.contains + data mismatch check with a full tuple check:

if !chunk.iter().any(|e| e.timestamp == d.timestamp && e.duration == d.duration && e.data == d.data) {
    stale.push(id);
}

This preserves intended behavior (delete stale replacements) while not deleting events that still exist in the source with different data at the same timestamp.

Ngôn ngữ chính
Rust
Star
320
Fork
101
Merge trung bình
3 ngày 17 giờ
Pull request đã merge (30 ngày)
47

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ActivityWatch/aw-server-rust

Tất cả issue của ActivityWatch/aw-server-rust

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.