aw-sync: 15 reproduced defects from a bug hunt (CLI list flags panic, interrupted sync leaves permanent gap, reconcile truncates edits, ...)

Đang mở
#875 2 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 1 ngày

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

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
15/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cli, rust, sqlite

Hướng nghiên cứu

This is a grab-bag of 17 independent defects, so pick one item rather than the list. Start by cloning the linked bughunt-2026-11-24-aw-sync-repros branch and running a single test, e.g. cargo test -p aw-sync --test bughunt_edge, then read the cited lines in aw-sync/src/sync.rs or main.rs. Done means that specific repro test goes green without breaking the rest of the aw-sync suite. Item 1 already has a suggested four-line fix at commit 7d09c72, which is the closest thing here to a startable entry point.

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

Mô tả

A review pass over aw-sync on master ea6f09c found the defects below. Every one has a test that fails on master. The tests are on a branch that is not meant for merging: TimeToBuildBob:bughunt-2026-11-24-aw-sync-repros. Run one file with cargo test -p aw-sync --test bughunt_<file>. The security and edge tests that start a server expect target/debug/aw-server to be built.

Crash (fix ready)
  1. Every list-valued CLI flag panics. This covers sync --buckets, sync --host, daemon --buckets and dedupe --bucket (main.rs:89,112,123,178). The fields are Option<Vec<String>> with value_parser=parse_list, which already returns a Vec, so clap panics on access with Mismatch between definition and access of 'buckets' and the process exits with 101. As a result, --buckets/--host filtering can't be used at all, and dedupe can never delete anything, because deleting requires --bucket.
    • Fix and unit test (red on master, green with the fix): 7d09c72, a 4-line type change to the ::std::vec::Vec opt-out. I can open it as a PR if wanted.
Data loss / wrong data
  1. An interrupted multi-page sync leaves a permanent gap. sync_one writes the newest page first (sync.rs:1186-1250) and resumes from the destination's newest event (sync.rs:1085). If a pass dies after page 1, every later pass resumes past the hole and reports "up to date". Ways that happens: SIGTERM (ctrlc is built without termination), an HTTP timeout, or Android killing the job. A peer can hit the same gap with no failure anywhere, by pulling a staging snapshot taken mid-push. Same root cause as #696, but a new trigger, and it hits push too; #789 only covers pull. Two independent reviewers found this one.
    • Tests: bughunt_concurrency.rs::interrupted_multipage_push_leaves_permanent_gap (4999 vs 5003), peer_pull_of_mid_push_snapshot_permanently_misses_older_events, and bughunt_errors.rs::partial_multipage_write_permanently_loses_older_events (4999 vs 12000).
  2. Editing an event that straddles the 7-day reconcile lookback truncates it permanently. get_events clips the event's start to lookback_start, so the timestamp >= lookback_start guards (sync.rs:1004,1017) never exclude it. Both sides then match on the clipped identity, the clipped source copy is inserted, and the full destination row is deleted (sync.rs:1055-1059). Example: a 10-day AFK event loses 3 days and 1 hour.
    • Test: bughunt_correctness.rs::reconcile_edit_of_event_straddling_lookback_start_truncates_it.
  3. A changed zero-duration latest event is duplicated instead of replaced. When the destination's newest event has duration 0, resume == its timestamp, so reconcile skips it on both sides (timestamp < resume). The incremental copy inserts the new version next to the stale one. The real trigger is a stopwatch timer that is synced while running and then stopped: the destination keeps a phantom running:true row. This is plausibly where #717's duplicated running rows come from.
    • Tests: stopped_stopwatch_leaves_phantom_running_row_on_dest, title_edit_of_zero_duration_latest_event_duplicates_it. Variant: stopped_overlapping_timer_is_truncated_on_dest, where a timer stopped while a second one runs is synced as 15 minutes instead of 25.
  4. One bucket with hostname == "unknown" blocks every bucket from that peer on pull. The refusal at sync.rs:874 sits inside collect::<Result<…>>()?, before the per-bucket skip loop. A hostname that only sanitizes to unknown is skipped per bucket, as intended. Two reviewers found this one.
    • Tests: bughunt_errors.rs::unknown_hostname_bucket_blocks_all_sibling_buckets_on_pull, bughunt_edge.rs::unknown_hostname_bucket_does_not_block_healthy_sibling_on_pull.
  5. A non-ASCII hostname is pushed as "unknown" and then refused by every peer. The device-id substitution at sync.rs:867 checks only the literal "unknown", before sanitizing (sync.rs:648,745). A bucket from host компьютер therefore lands in staging with hostname unknown.
    • Test: bughunt_edge.rs::non_ascii_hostname_survives_push_then_pull.
  6. Two overlapping pull passes import the same events twice. The resume point is read and the events are written later with no lock in between, and aw-sync has no single-instance lock. Example: the daemon with pull = true plus a manual aw-sync sync.
    • Test: bughunt_concurrency.rs::overlapping_pull_passes_duplicate_events (11 vs 7).
  7. If every peer fails on pull, the device stops pushing its own data. sync_run in Both mode returns before push (sync.rs:167-172,192-196), and so do plain sync (main.rs:373) and Android full sync (android.rs:350). One corrupt peer db is enough to stop publishing.
    • Repro: a garbage peer sync.db makes sync --mode both exit 1 and leaves its own staging db at 0 buckets; removing that peer makes it stage normally.
  8. dedupe flags distinct events as duplicates. Pages after the first use end = cut - 1ns, and the server clips each event ending after that bound (dedupe.rs:107). Two events with the same start and data but different durations, both crossing the cut, then compare equal. Deletion is currently blocked only by #1.
    • Test: bughunt_edge.rs::dedupe_does_not_flag_distinct_durations_straddling_page_cut.
Trust boundary: peers writing into a shared folder
  1. Push follows a symlink planted at its own staging path and migrates whatever sqlite file it points to. setup_local_remote / local_staging_db_path (sync.rs:293-311) check with exists() and open read-write. staging.rs and legacy_clean.rs both guard against symlinks; this path doesn't. In the test, a places.sqlite-like file comes out with aw tables, user_version=6 and WAL mode.
    • Test: bughunt_security.rs::push_follows_planted_symlink_and_migrates_foreign_sqlite_db.
      Not defects under the current trust model: aw-sync treats every participant in the sync folder as trusted, and anyone who can write that folder can already edit a peer's sync.db directly. These two are noted only because they show how an accident (two devices with the same or colliding hostname) turns into data loss. They belong to the device-identity work (#694, activitywatch#302), not this list:
  • A peer whose $aw.sync.origin/hostname matches another device's writes into that device's …-synced-from- bucket (sync.rs:601-622). Edit reconcile can then delete the real rows, and a far-future event freezes the resume point. Tests: peer_spoofing_origin_*.
  • The "keep largest db per device_id" rule (util.rs:620-631) lets any folder claiming a device_id shadow that device's real db. Test: foreign_folder_claiming_peer_device_id_shadows_real_peer.
Minor
  1. A per-bucket sync failure returns Ok, so the peer is reported as imported, 0 failed (sync.rs:908-930, 511-514). Test: per_bucket_failure_is_invisible_in_ok_result. Its assertion is stricter than the fix needs: a fix that surfaces the failure as a report warning would still fail it.
  2. Reconcile correctly deletes a pre-existing destination duplicate, but the "event count shrank" check (sync.rs:1313) then fails the bucket, and for a peer with a single bucket, the whole pass. Test: reconcile_dedup_reports_bucket_failure.
  3. A tie run longer than one page (5000 events at the same timestamp) loses its tail, and later passes add up to 5000 duplicates (sync.rs:1237-1241). This is mostly a risk for buckets that are already corrupted. Tests: tie_run_larger_than_a_page_*.
  4. A far-future event, for example from a clock that was briefly a year ahead, stops a bucket syncing until the wall clock catches up. This is the #696 family; the trigger is listed for completeness. Test: future_dated_event_from_clock_skew_stalls_bucket.
  5. Distinct devices whose names sanitize to the same string are merged into one bucket for host-less bucket ids such as aw-watcher-android-test. For example, Galaxy Маши and Galaxy Пети both become galaxy. Test: distinct_devices_with_colliding_sanitized_names_are_not_merged.

Suspicions that did not reproduce (left out): pull following symlinks (read-only), unvalidated --host path joins (local input only), and Syncthing .sync-conflict copies being picked by the largest-file rule (not tested).

An independent pass tried to refute each finding. It reclassified the two peer-spoofing items above as by-design, and every other item it checked held up.

Ngôn ngữ chính
Rust
Star
322
Fork
107
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
25

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.