feat: query cancellation via `CancellationToken` on `SessionContext`
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Área
- api, backend-api-design
Línea de trabajo
Comienza con los puntos de bloqueo de JNI en native/src/lib.rs e inspecciona los puntos de entrada de Java para SessionContext, DataFrame y los resource handles. Compara el ciclo de vida de tokens propuesto y las sobrecargas de collect/executeStream con las referencias de cancellation.rs y query_tracker.rs. Se considera terminado cuando las APIs enumeradas admiten cancelación y limpieza sin cambiar los métodos existentes sin token, y la cancelación puede observarse durante la recopilación y el streaming.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Is your feature request related to a problem or challenge?
A long-running DataFrame.collect(allocator) or DataFrame.executeStream(allocator) call blocks the calling Java thread for the entire duration of the query. Thread.interrupt() does nothing — the JNI thread is parked inside runtime().block_on(...) (native/src/lib.rs), and the interrupt flag is ignored by the Tokio runtime. There is no way to abort an in-flight query, free its native resources early, or unblock the calling thread short of waiting for the query to finish.
For any embedder running multi-tenant workloads — request timeouts, user-cancel actions, node shutdown, leader-election handover — this is a hard operational gap. The OpenSearch analytics backend (OpenSearch/sandbox/plugins/analytics-backend-datafusion/rust/src/cancellation.rs and query_tracker.rs) carries a CancellationToken-based wrapper precisely because upstream offers nothing.
This is complementary to issue #40 (close()/JNI use-after-free race) but distinct: #40 is about safely tearing down a finished handle; this is about signalling an in-flight future to stop. Both eventually share the atomic-handle scaffolding from #40's option 2, so coordination is worthwhile, but the surface lands cleanly without #40 having to merge first.
Describe the solution you'd like
A token-based cancellation API on SessionContext, modeled on Spark 4.0's interruptTag shape (cancel lives on the session, not on the DataFrame). The token is a separate handle from the DataFrame so cancel can fire from a thread that does not hold the DataFrame.
v1 surface
try (SessionContext ctx = new SessionContext();
CancellationToken token = ctx.newCancellationToken();
DataFrame df = ctx.sql("SELECT ... FROM big_table")) {
Future<ArrowReader> fut = pool.submit(() -> df.collect(allocator, token));
// from another thread (timeout watcher, user-cancel handler, ...):
token.cancel();
// fut completes with CancellationException
}
New methods:
SessionContext.newCancellationToken()-- returns a freshCancellationTokenbound to this session.CancellationToken.cancel()-- fires the token; idempotent.CancellationToken.isCancelled()-- non-blocking check.CancellationToken.close()-- releases the native handle; the token isAutoCloseableso try-with-resources handles cleanup.DataFrame.collect(BufferAllocator, CancellationToken)-- overload that takes a token. The existing zero-tokencollect(BufferAllocator)is unchanged.DataFrame.executeStream(BufferAllocator, CancellationToken)-- same overload pattern. Token is held by the returnedArrowReaderfor its full lifetime; cancel mid-stream aborts the nextloadNextBatch().
Describe alternatives you've considered
No response
Additional context
Out of scope
- Tag form. Ship the token primitive first; tag is sugar that can land in a follow-up if a user actually asks for it.
- Sync-API breakage.
df.collect(allocator)keeps working unchanged; the new method isdf.collect(allocator, token)(overload). - Per-operator cancel granularity. Today the cancel point is each
block_onsite; sub-operator cancellation is upstream-DataFusion territory.
- Lenguaje dominante
- Java
- Estrellas
- 32
- Forks
- 12
- Métricas de merge de PR
- Sin PR fusionados en 30 d
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 apache/datafusion-java
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
apache/datafusion-java#116 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
apache/datafusion-java#112 ·
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 42/100
apache/datafusion-java#96 ·
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
apache/datafusion-java#95 ·
-
Create first release Abiertoenhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
apache/datafusion-java#86 · 3 comentarios ·
Todos los issues de apache/datafusion-java
Issues similares
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apache/flink-agents#1152 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
jenkinsci/blueocean-plugin#5417 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
objectionary/eo-graphs#75 ·