Broadcast a plan to all cores and return raw binary payloads concatenated. Unlike `broadcast_to_all_cores` (which merges as JSON), this returns the raw response bytes. Each core's payload is appended as-is. Used by the two-phase join: phase 1 scans the right collection across all cores and collects raw msgpack, phase 2 passes it as `broadcast_data` to the join.
(
shared: &SharedState,
tenant_id: TenantId,
plan: PhysicalPlan,
trace_id: TraceId,
)
| 262 | /// two-phase join: phase 1 scans the right collection across all cores and |
| 263 | /// collects raw msgpack, phase 2 passes it as `broadcast_data` to the join. |
| 264 | pub async fn broadcast_raw( |
| 265 | shared: &SharedState, |
| 266 | tenant_id: TenantId, |
| 267 | plan: PhysicalPlan, |
| 268 | trace_id: TraceId, |
| 269 | ) -> crate::Result<Vec<u8>> { |
| 270 | BROADCAST_CALLS.fetch_add(1, Ordering::Relaxed); |
| 271 | let num_cores = shared |
| 272 | .dispatcher |
| 273 | .lock() |
| 274 | .unwrap_or_else(|p| p.into_inner()) |
| 275 | .num_cores(); |
| 276 | |
| 277 | let mut receivers = Vec::with_capacity(num_cores); |
| 278 | for core_id in 0..num_cores { |
| 279 | let request_id = shared.next_request_id(); |
| 280 | let vshard_id = VShardId::new(core_id as u32); |
| 281 | let request = Request { |
| 282 | request_id, |
| 283 | tenant_id, |
| 284 | database_id: DatabaseId::DEFAULT, |
| 285 | vshard_id, |
| 286 | plan: plan.clone(), |
| 287 | deadline: std::time::Instant::now() |
| 288 | + std::time::Duration::from_secs(shared.tuning.network.default_deadline_secs), |
| 289 | priority: crate::bridge::envelope::Priority::Normal, |
| 290 | trace_id, |
| 291 | consistency: ReadConsistency::Strong, |
| 292 | idempotency_key: None, |
| 293 | event_source: crate::event::EventSource::User, |
| 294 | user_roles: Vec::new(), |
| 295 | user_id: None, |
| 296 | statement_digest: None, |
| 297 | }; |
| 298 | |
| 299 | let rx = shared.tracker.register(request_id); |
| 300 | shared |
| 301 | .dispatcher |
| 302 | .lock() |
| 303 | .unwrap_or_else(|p| p.into_inner()) |
| 304 | .dispatch_to_core(core_id, request)?; |
| 305 | receivers.push(rx); |
| 306 | } |
| 307 | |
| 308 | let mut merged = Vec::new(); |
| 309 | for mut rx in receivers { |
| 310 | let resp = tokio::time::timeout( |
| 311 | std::time::Duration::from_secs(shared.tuning.network.default_deadline_secs), |
| 312 | async { rx.recv().await.ok_or(()) }, |
| 313 | ) |
| 314 | .await |
| 315 | .map_err(|_| crate::Error::Dispatch { |
| 316 | detail: "broadcast_raw timeout".into(), |
| 317 | })? |
| 318 | .map_err(|_| crate::Error::Dispatch { |
| 319 | detail: "broadcast_raw channel closed".into(), |
| 320 | })?; |
| 321 |
no test coverage detected