Fix locked task deletion

This commit is contained in:
Maurus Decimus
2026-04-30 12:55:52 +02:00
parent 7417d6d07c
commit cda4e49fef
4 changed files with 16 additions and 13 deletions

View File

@@ -259,15 +259,6 @@ pub(crate) async fn task_set(
continue;
}
if !set.server.try_lock_task(task_id).await {
set.response.not_destroyed.append(
id,
SetError::forbidden().with_description(
"Task is currently being processed and cannot be destroyed".to_string(),
),
);
continue;
}
locked_tasks.push(task_id);
let due = task.due_timestamp();

View File

@@ -24,7 +24,6 @@ impl TaskLockManager for Server {
TaskManager(TaskManagerEvent::TaskLocked),
Id = id,
Details = "Task details not available",
Expires = trc::Value::Timestamp(now() + DEFAULT_LOCK_EXPIRY),
);
}
result

View File

@@ -40,7 +40,7 @@ use store::rand::seq::SliceRandom;
use store::write::key::DeserializeBigEndian;
use store::{
IterateParams, ValueKey,
write::{BatchBuilder, TaskQueueClass, ValueClass, now},
write::{BatchBuilder, TaskQueueClass, ValueClass, assert::AssertValue, now},
};
use store::{SerializeInfallible, U64_LEN, rand};
use tokio::sync::{mpsc, watch};
@@ -574,6 +574,10 @@ async fn update_tasks(
u64::MAX
};
batch
.assert_value(
ValueClass::TaskQueue(TaskQueueClass::Task { id }),
AssertValue::Some,
)
.set(
ValueClass::TaskQueue(TaskQueueClass::Due { id, due }),
task.info.typ.to_id().serialize(),
@@ -587,7 +591,14 @@ async fn update_tasks(
}
if let Err(err) = server.store().write(batch.build_all()).await {
trc::error!(err.details("Failed to remove task(s) from queue."));
if err.matches(trc::EventType::Store(trc::StoreEvent::AssertValueFailed)) {
trc::event!(
TaskManager(TaskManagerEvent::TaskIgnored),
Reason = "Task was deleted while being processed; skipping update.",
);
} else {
trc::error!(err.details("Failed to remove task(s) from queue."));
}
}
for task in tasks {