feat(epic4): продолжение ожидающей Task после ввода (Story 4.5)
CI / UI Checks (pull_request) Successful in 8s
CI / Rust Checks (pull_request) Successful in 21m42s
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 21m42s
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 worker приостанавливает Task как input_required до dispatch, если закреплённая схема требует отсутствующее поле; authorized schema-validated update атомарно и с аудитом возобновляет тот же Task ровно один раз. Replay/conflict/TTL безопасны, ожидание удерживает admission permit. Additive schema v30: task_input_requests, fingerprint/version, TTL-индекс.
This commit is contained in:
1 parent
d80eda7329
commit
90e5357a08
35 files changed
+3243
-91
No files matched your search
@@ -26,9 +26,11 @@ use super::admission::{AdmissionLimits, AttemptError};
|
||||
|
||||
mod acceptance;
|
||||
mod attempts;
|
||||
mod input;
|
||||
|
||||
const TASK_PROJECTION: &str = "task_id, state, workspace_id, owner_kind, owner_id,
|
||||
authorization_scope, platform_api_key_id, operation_id, input_fingerprint, operation_version,
|
||||
authorization_scope, platform_api_key_id, operation_id, input_fingerprint,
|
||||
effective_input_fingerprint, operation_version,
|
||||
policy_mode,
|
||||
approval_reference,
|
||||
request_id, trace_id, traceparent, trace_sampled, input_envelope, progress_envelope,
|
||||
@@ -521,7 +523,49 @@ and lease_owner is null
|
||||
transaction.commit().await.map_err(Self::unavailable)?;
|
||||
|
||||
let mut leases = Vec::new();
|
||||
for _ in 0..batch {
|
||||
// Continuation claim: after a committed answer the Task is `working` without a lease and still
|
||||
// owns its executing admission permit. It is handed to exactly one new fence here, without a
|
||||
// second admission grant, so waiting capacity is never double-counted.
|
||||
let mut transaction = self.start().await?;
|
||||
let resumed = sqlx::query(sqlx::AssertSqlSafe(format!(
|
||||
"update tasks
|
||||
set lease_owner = $1,
|
||||
lease_until = clock_timestamp() + ($2::bigint || ' milliseconds')::interval,
|
||||
fence = fence + 1,
|
||||
updated_at = now()
|
||||
where task_id in (
|
||||
select t.task_id
|
||||
from tasks t
|
||||
join task_input_requests r on r.task_id = t.task_id and r.accepted_at is not null
|
||||
join execution_admission_entries e
|
||||
on e.task_id = t.task_id and e.state = 'executing'
|
||||
where t.state = 'working' and t.lease_owner is null
|
||||
and t.current_attempt_id is null
|
||||
order by t.task_id
|
||||
limit $3
|
||||
for update of t skip locked
|
||||
)
|
||||
returning {TASK_PROJECTION}"
|
||||
)))
|
||||
.bind(owner)
|
||||
.bind(lease_ms)
|
||||
.bind(i64::try_from(batch.clamp(1, 64)).unwrap_or(64))
|
||||
.fetch_all(&mut *transaction)
|
||||
.await
|
||||
.map_err(Self::unavailable)?;
|
||||
transaction.commit().await.map_err(Self::unavailable)?;
|
||||
for row in resumed {
|
||||
let record = record_from_row(&row).map_err(Self::unavailable)?;
|
||||
leases.push(TaskLease {
|
||||
owner: owner.to_owned(),
|
||||
fence: record.fence,
|
||||
lease_until: record.lease_until_unix_ms.unwrap_or_default(),
|
||||
record,
|
||||
});
|
||||
}
|
||||
|
||||
let remaining = batch.saturating_sub(leases.len());
|
||||
for _ in 0..remaining {
|
||||
let mut transaction = self.start().await?;
|
||||
let workspace_cursor =
|
||||
match super::admission::lock_admission_in_tx(&mut transaction, "*").await {
|
||||
@@ -840,6 +884,9 @@ fn record_from_row(row: &sqlx::postgres::PgRow) -> Result<TaskRecord, TaskError>
|
||||
.map(PlatformApiKeyId::new),
|
||||
operation_id: row.try_get("operation_id").map_err(unavailable_row)?,
|
||||
input_fingerprint: row.try_get("input_fingerprint").map_err(unavailable_row)?,
|
||||
effective_input_fingerprint: row
|
||||
.try_get("effective_input_fingerprint")
|
||||
.map_err(unavailable_row)?,
|
||||
pins: TaskPins {
|
||||
operation_version: u32::try_from(
|
||||
row.try_get::<i32, _>("operation_version")
|
||||
|
||||
Reference in new issue
Block a user