sqlite: applyChangeset() keeps part of the changeset when the filter callback throws
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, nodejs, sqlite
- Área
- database
Línea de trabajo
Start with the node:sqlite DatabaseSync.applyChangeset() implementation and its API documentation, then run the provided reproducer against the current build. Trace how filter callback errors affect the SQLite changeset application and whether the transaction can be rolled back. Done should establish the intended behavior and add a regression test covering a filter that throws after an earlier table was accepted.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Version
main (1724da82b, v28.0.0-pre); v22.22.2 for the abort below
Platform
Linux 5.15.0-139-generic x86_64
Subsystem
sqlite
What steps will reproduce the bug?
const { DatabaseSync } = require('node:sqlite');
const make = () => {
const db = new DatabaseSync(':memory:');
db.exec('CREATE TABLE a(id INTEGER PRIMARY KEY, v); CREATE TABLE b(id INTEGER PRIMARY KEY, v)');
return db;
};
const source = make();
const session = source.createSession();
source.exec("INSERT INTO a VALUES (1, 'x'); INSERT INTO b VALUES (1, 'y')");
const target = make();
try {
target.applyChangeset(session.changeset(), {
filter(table) {
if (table === 'b') throw new Error('filter failed for b');
return true;
},
});
} catch (err) {
console.log('threw:', err.message);
}
console.log('a:', target.prepare('SELECT count(*) AS n FROM a').get().n);
console.log('b:', target.prepare('SELECT count(*) AS n FROM b').get().n);
How often does it reproduce? Is there a required condition?
Always, when the filter callback throws for a table after it has accepted another one.
What is the expected behavior? Why is that the expected behavior?
Either the changeset is not applied at all when applyChangeset() throws, or the
documentation says that the changes of the tables accepted before the exception
remain applied.
For onConflict, the documentation states: "When an error is thrown in the
conflict handler or when any other value is returned from the handler, applying
the changeset is aborted and the database is rolled back." A caller who sees
applyChangeset() throw would reasonably expect the same for filter, which the
documentation does not cover.
What do you see instead?
threw: filter failed for b
a: 1
b: 0
applyChangeset() throws, but the changes for table a have been applied. The
failed filter call makes xFilter skip the remaining tables, and
sqlite3changeset_apply() returns SQLITE_OK for the tables that were
accepted (#64823 notes that a falsy filter result is not a SQLite error).
Additional information
On v22.22.2 the same script aborts the process instead
(FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal in
node::sqlite::DatabaseSync::ApplyChangeset, exit code 134). The v22.x branch
still calls ToLocalChecked() on the filter result; #60028, which fixed this on
main and is in v24.x, does not seem to have been backported to v22.x.
This was found by an LLM-assisted static analysis tool; I reproduced both
behaviours myself on a local build of main and on v22.22.2.
- Lenguaje dominante
- JavaScript
- Estrellas
- 124k
- Forks
- 38k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 266
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 nodejs/node
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
Los mantenedores suelen responder en 1 día
-
fs: document readStream.start and readStream.endPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertodoc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
nodejs/node#67848 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
doc: document the Buffer.prototype.*Slice() methodsPosiblemente ocupada @AyushCipher la tomó hoy. Abiertodoc
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
nodejs/node#67847 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
`styleText` fast path bypasses `options` and `options.validateStream` validationPosiblemente ocupada @GBra-4-669 la tomó hace 8 días. Abiertoutil
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
riscv64
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
nodejs/node#67655 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de nodejs/node
Issues similares
-
bug triage needed
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
[Resource]: PersephoneAbiertoresource-submission validation-passed
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
hesreallyhim/awesome-claude-code#3773 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
tabatkins/railroad-diagrams#129 ·
-
web: api() turns a null or object-valued error body into a TypeError or "[object Object]" and loses the statusPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día