Correctness bugs: heartbeat cache, query cache invalidation, commit rollback state
维护者通常 1 天内回复
评估
调研方向
The issue identifies four areas: aw-datastore/src/worker.rs, aw-server/src/android/mod.rs, aw-server/src/endpoints/query.rs, and commit handling in work_loop. Start by reviewing the linked fixes #826, #827, #830, and #831 and the described repro steps. Done means each cache or in-memory state remains consistent after the relevant delete, write, race, or failed commit.
由索引模型根据 Issue 内容生成。
描述
A correctness review of master (at 1d101d4) found the following bugs. Fixing PRs will be linked to the items below as they land.
-
Stale heartbeat cache after deleting events, deleting a bucket, or renaming a bucket. — fix: #826
The datastore worker caches each bucket's last heartbeat (last_heartbeatinaw-datastore/src/worker.rs). It is invalidated onInsertEvents, but not onDeleteEventsById,DeleteBucketorRenameBucket. The next heartbeat with the same data then merges into a row that no longer exists, and fails with:InternalError("replace_last_event matched 0 rows for event_id 1 - cache/DB inconsistency")That heartbeat is lost and the client gets a 500. The heartbeat after that recovers, because the bad cache entry is removed before the error. Repro: send two heartbeats, then either delete the latest event or delete and re-create the bucket, then send another heartbeat with the same data. This is easy to hit by deleting the current event from the web UI while a watcher is running.
-
On Android, JNI writes skip query-cache invalidation. — fix: #831
The query cache is enabled by default on Android too (server_state.query_cache_enabled = server_config.query_cacheinaw-server/src/android/mod.rs). But the JNI functionsheartbeat,createBucket,migrateHostnameand the bucket renames write straight to the datastore. The cache is only invalidated in the HTTP handlers (endpoints/bucket.rs,endpoints/import.rs). So when the usage watcher backfills events for a past day after the web UI has cached that day, the stale result is served until the app restarts. Bucket creates and renames over JNI also leave cachedfind_bucketresults wrong. -
A race in the query endpoint can cache a stale result when a read-only reader is in use. — fix: #827
query()inaw-server/src/endpoints/query.rsflushes pending writes once, at the start of the request (pending_overlapping/force_commit). It readsquery_cache.generation()later, once per period. Suppose a write to a past period arrives mid-request. Itsinvalidate()has already run when a later period reads the generation, so that period's generation includes the write. But the period is evaluated on the reader, which cannot see the write until the writer's batch commits.put()then finds no newer overlapping write and stores the stale result, which stays until another write touches that range. This needs a multi-period request (Year / All time views) running while past events are edited or imported. -
A failed commit leaves the worker's in-memory state out of sync with the database. — fix: #830
Whentx.commit()fails inwork_loop, only the privacy engine is restored. The bucket cache inDatastoreInstanceand thelast_heartbeatcache keep the rolled-back changes:- A bucket whose creation was rolled back is still listed.
- A bucket whose deletion was rolled back disappears.
- Cached heartbeats can point at rows that were rolled back.
The legacy-import path already rebuilds
DatastoreInstanceafter a rollback. Doing the same here, and clearinglast_heartbeat, would fix it. This only happens on real commit failures, such as a full disk.
- 主要语言
- Rust
- 星标
- 322
- 派生
- 105
- 平均合并
- 3 天 10 小时
- 30 天内合并 PR
- 22
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ActivityWatch/aw-server-rust 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
ActivityWatch/aw-server-rust#798 · 1 条评论 ·
维护者通常 1 天内回复
-
Allow configuring sync dir in the `aw-sync/config.toml` file可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 58/100
ActivityWatch/aw-server-rust#853 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
ActivityWatch/aw-server-rust#793 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 65/100
ActivityWatch/aw-server-rust#790 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 45/100
ActivityWatch/aw-server-rust#717 · 2 条评论 ·
维护者通常 1 天内回复
查看 ActivityWatch/aw-server-rust 的全部 Issue
相似的 Issue
-
area:compat area:operations documentation ready-for-agent type:afk
难度 2/5 1-3 小时 新手友好度 74/100
ZcashFoundation/zinder#552 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 65/100
storytold/vectorcraft#9229 ·
维护者通常 1 天内回复