prune_kv_values_updated_before emits actions in HashMap order; replay fails with `kv clear mismatch`
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- node.js, rust
调研方向
Start in src/lib.rs at prune_kv_values_updated_before (around lines 3411-3427), then inspect get_kv_all_keys around lines 3360-3362 and the kv_metadata declaration around line 1715. Reproduce the Node.js SDK scenario with multiple matching keys and verify that replay emits and consumes KV actions in a consistent order.
由索引模型根据 Issue 内容生成。
描述
Summary
An orchestration that prunes two or more KV keys in one turn fails on a later replay with nondeterministic: kv clear mismatch. The orchestration code is deterministic. The order of the actions that the runtime emits is not.
Where
prune_kv_values_updated_beforeiterateskv_metadataand callsclear_kv_valuefor each key: https://github.com/microsoft/duroxide/blob/6a458861763a7aa5b78a7c1c97691a6f00489a8b/src/lib.rs#L3411-L3427kv_metadatais astd::collections::HashMap: https://github.com/microsoft/duroxide/blob/6a458861763a7aa5b78a7c1c97691a6f00489a8b/src/lib.rs#L1715get_kv_all_keysreturns the keys inHashMaporder as well: https://github.com/microsoft/duroxide/blob/6a458861763a7aa5b78a7c1c97691a6f00489a8b/src/lib.rs#L3360-L3362
A HashMap has a random seed per map. So the iteration order differs between two replays of the same turn, also inside one process.
How it fails
- Execution 1 writes the keys
atofand continues as new. - Execution 2 calls
prune_kv_values_updated_before(cutoff). All six keys match. The turn records sixKeyValueClearedevents in some order. - A later turn replays the same code. The six
ClearKeyValueactions come out in a different order. - The replay engine compares the first action with the first event, finds another key, and fails the orchestration.
Reproduction
Reproduced with duroxide 0.1.30 on SQLite, through the Node.js SDK:
runtime.registerOrchestration('Prune', function* (ctx, input) {
if (!input || !input.second) {
for (const k of ['a', 'b', 'c', 'd', 'e', 'f']) ctx.setValue(k, 'x');
yield ctx.continueAsNew({ second: true });
return '';
}
const now = yield ctx.utcNow();
const pruned = ctx.pruneKvValuesUpdatedBefore(now + 60_000); // clears all six keys
yield ctx.utcNow();
yield ctx.utcNow();
return `pruned ${pruned}`;
});
6 of 6 instances failed, for example with:
nondeterministic: kv clear mismatch: action=ClearKeyValue { key: "d" } vs event=KeyValueCleared { key: "a" }
Impact
- An orchestration that calls
prune_kv_values_updated_beforewith more than one matching key can fail for good. With n keys, two replays agree on the order with a chance of 1 in n!. get_kv_all_keysandget_kv_all_valueshand the same random order to orchestration code. Code that loops over the result and schedules work per key is nondeterministic for the same reason.
Suggested fix
- Sort the keys in
prune_kv_values_updated_beforebefore the actions are emitted. - Return sorted keys from
get_kv_all_keys, or keep the KV state in aBTreeMap.
Tracked in #55.
- 主要语言
- Rust
- 星标
- 226
- 派生
- 62
- 平均合并
- 20 小时 46 分钟
- 30 天内合并 PR
- 6
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/duroxide 的其他 Issue
-
bug
难度 3/5 1-2 天 新手友好度 74/100
维护者通常 1 天内回复
-
One failed session lock renewal loses the session: no retry, no log, no signal to running activities未关闭bug
难度 4/5 3-5 天 新手友好度 30/100
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 72/100
维护者通常 1 天内回复
-
bug
难度 5/5 一周以上 新手友好度 38/100
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
查看 microsoft/duroxide 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
farion1231/cc-switch#8829 · 1 条评论 ·
维护者通常 1 天内回复
-
Validate CI command vectors before indexing Cargo subcommands可能已有人在做 @amandeavor 今天认领。 未关闭bug ci good first issue
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
longbridge/gpui-kit#3677 ·
维护者通常 1 天内回复
-
E-pr-welcome
难度 2/5 1-3 小时 新手友好度 77/100
seanmonstar/reqwest#3121 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
ilya-zlobintsev/LACT#1235 ·
维护者通常 1 天内回复