aw-sync: no stored cursor — resume-from-destination silently never syncs late-arriving events
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- backend, databases, distributed-systems
Direzione di ricerca
Start at sync_one and trace the current destination-based resume logic, including get_events pagination and boundary_ts handling. Design the per-source cursor and migration behavior described in the proposal, then verify that late-arriving events are picked up and separate source buckets do not share progress. Done means the timestamp boundary loop is no longer needed and existing installs retain a usable resume point.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
sync_one has no stored cursor. It infers where to resume by reading the newest event already in the destination:
let most_recent_events = ds_to.get_events(bucket_to.id.as_str(), None, None, Some(1))?;
let resume_sync_at = most_recent_events
.first()
.map(|e| e.timestamp + e.duration)
.or(sync_spec.start);
then fetches only events newer than that. The destination copy is being used as its own progress marker.
Consequence 1: events that arrive late never sync, silently
Events are not always appended in timestamp order. An importer (aw-import-*, screentime imports), a retroactively edited stopwatch entry, or any backfill writes events with timestamps older than the bucket's current newest. Those events are permanently invisible to sync: the cursor is already past them, and nothing ever looks back. No error, no warning — the pass reports ✓ Already up to date!.
Consequence 2: it is the mechanism behind #683
Because the cursor lives in the destination rather than being per-source, two folders for one device write into the same destination bucket and the first one to be imported sets the resume point for the second. That is how a 4,068-event partial slice silently suppressed 1,027,343 events of real history. #686 fixes the trigger (duplicate folders) but the amplifier is this cursor design.
Consequence 3: it forces the fragile pagination
Because the cursor is a timestamp, sync_one has to reason carefully about events sharing an identical timestamp at page boundaries — the boundary_ts tie-handling loop, with a documented pathological case it explicitly declines to handle. A monotonic source-side cursor removes that reasoning entirely.
Proposal
Store an explicit cursor per (source_device_id, source_bucket_id) on the destination, keyed by the source's events.id rowid, which is monotonic in insertion order:
sync_cursor(source_device_id, source_bucket_id, last_source_rowid, updated)
- Fetch
WHERE id > last_source_rowid ORDER BY id LIMIT n— no timestamp ties, no boundary loop, and late-arriving events are picked up because they get a new rowid even though their timestamp is old. - Initialise from today's resume-from-newest so existing installs migrate with no re-import.
- Per-source keying means two folders for one device cannot contaminate each other's progress.
Caveat worth designing around: rowids are only monotonic within one source database. If a peer's staging db is rebuilt from scratch its rowids restart, so the cursor needs to be invalidated when the source's identity or generation changes — which is another argument for per-device metadata in the folder (ActivityWatch/activitywatch#302, #691). A cheap interim guard is to store the source's event count alongside the cursor and reset if it goes backwards.
Credit: found in a design review of aw-sync.
Related: #683, #686, #691, ActivityWatch/activitywatch#302.
cc @TimeToBuildBob
- Lingua principale
- Rust
- Stelle
- 315
- Fork
- 97
- Merge medio
- 1g 10h
- PR unite (30g)
- 61
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ActivityWatch/aw-server-rust
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
ActivityWatch/aw-server-rust#763 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
ActivityWatch/aw-server-rust#724 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
ActivityWatch/aw-server-rust#717 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
ActivityWatch/aw-server-rust#714 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Imported (-synced-from-) buckets are writable and unmarked; local writes to them are silently lostApertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
ActivityWatch/aw-server-rust#694 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ActivityWatch/aw-server-rust
Issue simili
-
type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
stackabletech/kafka-operator#1033 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue needs testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 3 giorni
-
docs: release notes v3.7.0–v3.8.0 footer links to README/CHANGELOG are broken after docs reorgAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
farion1231/cc-switch#7744 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
datafusion
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/iceberg-rust#3297 ·
I maintainer di solito rispondono entro 1 giorno