feat(epic4): безопасные повторы и отмена durable Task (Story 4.4)
CI / UI Checks (pull_request) Successful in 8s
CI / Rust Checks (pull_request) Successful in 20m46s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
CI / UI Checks (pull_request) Successful in 8s
CI / Rust Checks (pull_request) Successful in 20m46s
CI / Rust Feature Validation (pull_request) Skipped
CI / Frontend E2E (pull_request) Skipped
CI / Community Image Smoke (pull_request) Skipped
CI / Required Checks (pull_request) Successful in 1s
CI / Deploy (pull_request) Skipped
Durable per-outbound attempt до отправки запроса, bounded retry/read, server-owned verified writes, честный cancel/unknown, deadline/fencing, additive schema v29. Staged renames task.rs/tasks.rs разложены на модули. Includes disclosed cosmetic parity exception: единственная правка вне принятой дельты — удалена лишняя пустая строка в конце scripts/ci-story-checks.sh (EOF blank line); story-код не менялся.
This commit is contained in:
1 parent
8c02380762
commit
a3057de51e
44 files changed
+4547
-815
No files matched your search
@@ -15,8 +15,7 @@ use super::*;
|
||||
async fn task_worker_stop_between_checkpoint_and_dispatch_never_reaches_upstream() {
|
||||
use crank_core::{TaskAccess, TaskLease, TaskOwnerKind};
|
||||
use crank_runtime::{
|
||||
TaskAttemptOutcome, TaskDispatchPermit, TaskHandler, TaskWorker, TaskWorkerConfig,
|
||||
TaskWorkerError,
|
||||
TaskAttemptOutcome, TaskHandler, TaskWorker, TaskWorkerConfig, TaskWorkerError,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
@@ -67,6 +66,7 @@ async fn task_worker_stop_between_checkpoint_and_dispatch_never_reaches_upstream
|
||||
execution_deadline_unix_ms: 1_900_000_000_000,
|
||||
retain_until_unix_ms: 1_900_000_000_000 + 60_000,
|
||||
approval_reference: None,
|
||||
retry: crank_core::TaskRetryPolicy::single_attempt(),
|
||||
},
|
||||
scoped_key: scoped_key.repeat(64),
|
||||
input_fingerprint: scoped_key.repeat(64),
|
||||
@@ -101,15 +101,44 @@ async fn task_worker_stop_between_checkpoint_and_dispatch_never_reaches_upstream
|
||||
let _ = self.release.acquire().await;
|
||||
Ok(())
|
||||
}
|
||||
async fn execute(
|
||||
&self,
|
||||
_lease: &TaskLease,
|
||||
_attempt_id: &str,
|
||||
_cancelled: Arc<std::sync::atomic::AtomicBool>,
|
||||
_permit: TaskDispatchPermit,
|
||||
) -> TaskAttemptOutcome {
|
||||
async fn execute(&self, context: crank_runtime::TaskAttemptContext) -> TaskAttemptOutcome {
|
||||
// The trigger delays the durable checkpoint; a stop that lands while it is in flight must
|
||||
// finalize failed(shutdown_before_dispatch) without an outbound send.
|
||||
let begin = crank_core::BeginAttempt {
|
||||
task_id: context.lease().record.task_id,
|
||||
owner: context.lease().owner.clone(),
|
||||
fence: context.lease().fence,
|
||||
expected_version: context.lease().record.version,
|
||||
attempt_id: "attempt-stop-window".to_owned(),
|
||||
input_fingerprint: context.lease().record.input_fingerprint.clone(),
|
||||
upstream_key_digest: None,
|
||||
retry_allowed: false,
|
||||
};
|
||||
let Ok(attempt) = context.store().checkpoint_dispatch(begin).await else {
|
||||
return TaskAttemptOutcome::Stopped;
|
||||
};
|
||||
if context.is_stopping() {
|
||||
let _ = context
|
||||
.store()
|
||||
.resolve_attempt(
|
||||
&attempt,
|
||||
crank_core::AttemptOutcome::Failed {
|
||||
error: crank_core::TaskEnvelope::try_redacted(&json!({
|
||||
"code": "shutdown_before_dispatch",
|
||||
"phase": "before_dispatch",
|
||||
}))
|
||||
.expect("bounded error envelope"),
|
||||
retryable: false,
|
||||
phase: crank_core::AttemptPhase::BeforeDispatch,
|
||||
},
|
||||
)
|
||||
.await;
|
||||
return TaskAttemptOutcome::Failed {
|
||||
code: "shutdown_before_dispatch".to_owned(),
|
||||
};
|
||||
}
|
||||
self.executed.fetch_add(1, Ordering::SeqCst);
|
||||
TaskAttemptOutcome::Completed(json!({ "ok": true }))
|
||||
commit_attempt(&context, completed_outcome(json!({ "ok": true }))).await
|
||||
}
|
||||
}
|
||||
let handler: Arc<dyn TaskHandler> = Arc::new(GatedHandler {
|
||||
@@ -117,14 +146,15 @@ async fn task_worker_stop_between_checkpoint_and_dispatch_never_reaches_upstream
|
||||
release: revalidate_release.clone(),
|
||||
executed: executed.clone(),
|
||||
});
|
||||
let mut config = TaskWorkerConfig::default();
|
||||
config.owner = "runtime-worker-stop-window".to_owned();
|
||||
config.batch_limit = 1;
|
||||
config.lease_ms = 30_000;
|
||||
config.poll_interval = Duration::from_millis(50);
|
||||
config.renewal_interval = Duration::from_secs(20);
|
||||
config.max_inflight = 1;
|
||||
config.shutdown_timeout = Duration::from_secs(20);
|
||||
let config = TaskWorkerConfig {
|
||||
owner: "runtime-worker-stop-window".to_owned(),
|
||||
batch_limit: 1,
|
||||
lease_ms: 30_000,
|
||||
poll_interval: Duration::from_millis(50),
|
||||
renewal_interval: Duration::from_secs(20),
|
||||
max_inflight: 1,
|
||||
shutdown_timeout: Duration::from_secs(20),
|
||||
};
|
||||
let worker = TaskWorker::new(store.clone(), handler, config).expect("valid worker");
|
||||
let stop_flag = worker.stop_flag();
|
||||
let worker_task = tokio::spawn(async move { worker.run().await });
|
||||
|
||||
Reference in new issue
Block a user