prune_kv_values_updated_before emits actions in HashMap order; replay fails with `kv clear mismatch`
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- node.js, rust
- Área
- distributed-systems
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 221
- Forks
- 61
- Merge medio
- 3 d 5 h
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/duroxide
-
One failed session lock renewal loses the session: no retry, no log, no signal to running activitiesAbiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
-
bug
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
A failed activity lock renewal can lose the activity result; the orchestration waits foreverAbiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Todos los issues de microsoft/duroxide
Issues similares
-
app enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
elodin-sys/elodin#890 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
guidance-ai/llguidance#391 ·
-
documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Verifiedz/Shimmer#144 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
点击设置提示`操作未能完成,详情请查看应用日志`Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Y-ASLant/ElegantClipboard#166 ·