Dispatch a single PhysicalTask. Broadcast plans (scans, InsertSelect) are handled locally; all other tasks flow through `dispatch_task_via_gateway` which routes via the gateway when available, or falls back to the local SPSC path on single-node boot.
(ctx: &DispatchCtx<'_>, task: PhysicalTask)
| 254 | /// flow through `dispatch_task_via_gateway` which routes via the gateway when |
| 255 | /// available, or falls back to the local SPSC path on single-node boot. |
| 256 | async fn dispatch_task(ctx: &DispatchCtx<'_>, task: PhysicalTask) -> crate::Result<Response> { |
| 257 | if matches!( |
| 258 | task.plan, |
| 259 | crate::bridge::envelope::PhysicalPlan::Document( |
| 260 | nodedb_physical::physical_plan::DocumentOp::InsertSelect { .. } |
| 261 | ) |
| 262 | ) { |
| 263 | return broadcast_count_to_all_cores( |
| 264 | ctx.state, |
| 265 | task.tenant_id, |
| 266 | task.plan, |
| 267 | TraceId::ZERO, |
| 268 | "inserted", |
| 269 | ) |
| 270 | .await; |
| 271 | } |
| 272 | |
| 273 | // `DROP ARRAY` fans out to every core so per-core stores are released. |
| 274 | if matches!( |
| 275 | task.plan, |
| 276 | crate::bridge::envelope::PhysicalPlan::Array( |
| 277 | nodedb_physical::physical_plan::ArrayOp::DropArray { .. } |
| 278 | ) |
| 279 | ) { |
| 280 | return broadcast_count_to_all_cores( |
| 281 | ctx.state, |
| 282 | task.tenant_id, |
| 283 | task.plan, |
| 284 | TraceId::ZERO, |
| 285 | "dropped", |
| 286 | ) |
| 287 | .await; |
| 288 | } |
| 289 | |
| 290 | // Broadcast scans must fan-out to all cores regardless of gateway state. |
| 291 | if task.plan.is_broadcast_scan() { |
| 292 | return broadcast_to_all_cores(ctx.state, task.tenant_id, task.plan, TraceId::ZERO).await; |
| 293 | } |
| 294 | |
| 295 | // All other tasks — point ops, writes, Raft-replicated writes — route |
| 296 | // through the gateway when available (cluster-aware routing + retry), |
| 297 | // or via the local SPSC path when the gateway is not yet wired. |
| 298 | dispatch_task_via_gateway(ctx, task).await |
| 299 | } |
| 300 | |
| 301 | // ─── SET / SHOW / RESET (SQL form) ───────────────────────────────── |
| 302 |
no test coverage detected