fix: allow slow initial input commits

This commit is contained in:
2026-09-07 20:21:22 +09:00
parent 2fd043b634
commit c76ede2ab4
3 changed files with 27 additions and 5 deletions
+9 -1
View File
@@ -786,9 +786,15 @@ impl Runtime {
) -> Result<WorkerDetail, RuntimeError> {
let worker_id = request.worker_id;
let workspace_id = scope.map(|scope| scope.workspace_id.as_str());
let started_at = std::time::Instant::now();
let result = self.create_worker_with_workspace_inner(request, scope);
if let Err(error) = &result {
write_runtime_worker_create_failure(worker_id, workspace_id, error);
write_runtime_worker_create_failure(
worker_id,
workspace_id,
error,
started_at.elapsed(),
);
}
result
}
@@ -3470,6 +3476,7 @@ fn write_runtime_worker_create_failure(
worker_id: WorkerId,
workspace_id: Option<&str>,
error: &RuntimeError,
elapsed: std::time::Duration,
) {
let (error_kind, operation, outcome) = runtime_worker_create_failure_fields(error);
let execution_failure_code = match error {
@@ -3488,6 +3495,7 @@ fn write_runtime_worker_create_failure(
operation = operation.as_deref().unwrap_or(""),
outcome = outcome.as_deref().unwrap_or(""),
execution_failure_code,
duration_ms = u64::try_from(elapsed.as_millis()).unwrap_or(u64::MAX),
"Worker creation failed"
);
}
+11 -2
View File
@@ -90,11 +90,11 @@ use worker::{
const DEFAULT_BACKEND_ID: &str = "worker-crate";
const RUNTIME_TASK_TIMEOUT: Duration = Duration::from_secs(10);
const SPAWN_RESTORE_TASK_TIMEOUT: Duration = Duration::from_secs(60);
const USER_INPUT_TASK_TIMEOUT: Duration = Duration::from_secs(35);
const USER_INPUT_TASK_TIMEOUT: Duration = Duration::from_secs(125);
const WORKSPACE_CONFIG_HTTP_TIMEOUT: Duration = Duration::from_secs(8);
const MAX_WORKSPACE_CONFIG_RESPONSE_BYTES: usize = 72 * 1024 * 1024;
// Leave adapter cancellation margin after the durable submission deadline.
const USER_INPUT_COMMIT_TIMEOUT: Duration = Duration::from_secs(30);
const USER_INPUT_COMMIT_TIMEOUT: Duration = Duration::from_secs(120);
pub struct RuntimeWorkerController {
pub handle: WorkerHandle,
@@ -2541,6 +2541,15 @@ mod tests {
WorkerExecutionContext::new(worker_ref)
}
#[test]
fn input_commit_budget_leaves_adapter_cancellation_margin() {
assert!(USER_INPUT_TASK_TIMEOUT > USER_INPUT_COMMIT_TIMEOUT);
assert_eq!(
USER_INPUT_TASK_TIMEOUT - USER_INPUT_COMMIT_TIMEOUT,
Duration::from_secs(5)
);
}
struct DelayedFactory {
completed: Arc<AtomicBool>,
delay: Duration,