feat: query cancellation via `CancellationToken` on `SessionContext`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Ambito
- api, backend-api-design
Direzione di ricerca
Inizia dai punti di blocco JNI in native/src/lib.rs ed esamina gli entry point Java per SessionContext, DataFrame e i resource handle. Confronta il ciclo di vita dei token proposto e gli overload di collect/executeStream con i riferimenti in cancellation.rs e query_tracker.rs. Il lavoro è completo quando le API elencate supportano la cancellazione e la pulizia senza modificare i metodi esistenti senza token, con la cancellazione osservabile durante la raccolta e lo streaming.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 32
- Fork
- 12
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/datafusion-java
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
apache/datafusion-java#116 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
apache/datafusion-java#112 ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
apache/datafusion-java#96 ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
apache/datafusion-java#95 ·
-
Create first release Apertaenhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
apache/datafusion-java#86 · 3 commenti ·
Tutte le issue di apache/datafusion-java
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
elastic/gradle-plugins#157 ·
-
enhancement Tools
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
apache/rocketmq-dashboard#5008 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
DETECT_PARAMETER_NAMES=false silently disables @ConstructorProperties-based Creator detection too Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
FasterXML/jackson-databind#6229 ·