diff --git a/backend/app/services/tasks/worker.py b/backend/app/services/tasks/worker.py index c40c5de1..3b0bc97a 100644 --- a/backend/app/services/tasks/worker.py +++ b/backend/app/services/tasks/worker.py @@ -207,13 +207,14 @@ def _finalize_completed(task_type: TaskType, user_id) -> None: def _finalize_dead_letter( task_type: TaskType, payload: dict, user_id, *, error: Exception ) -> None: - """終端ステータス(dead_letter)への更新と失敗通知をまとめて行う。""" + """終端ステータス(dead_letter)への更新と失敗通知を行う。 - def work(db: Session) -> None: - _mark_dead_letter(db, task_type, payload, error=error) - _notify_if_real_user(db, task_type, user_id, "failed") - - _run_in_new_session(work) + ``_mark_dead_letter`` は DB エラーを握りつぶす(rollback しない)ため、commit 失敗時に + セッションが失効状態のまま残りうる。通知作成が汚染セッションを再利用しないよう、 + 状態更新と通知はそれぞれ独立した新規セッションで実行する。 + """ + _run_in_new_session(lambda db: _mark_dead_letter(db, task_type, payload, error=error)) + _run_in_new_session(lambda db: _notify_if_real_user(db, task_type, user_id, "failed")) def _finalize_retrying( diff --git a/backend/tests/test_worker/test_github_link.py b/backend/tests/test_worker/test_github_link.py index c50af5c2..add2dc9f 100644 --- a/backend/tests/test_worker/test_github_link.py +++ b/backend/tests/test_worker/test_github_link.py @@ -199,6 +199,7 @@ def test_contribution_calendar_persisted_in_result( db_session.refresh(cache) assert cache.status == "completed" + assert cache.result is not None assert cache.result["contribution_calendar"]["total_contributions"] == 7 assert cache.result["contribution_calendar"]["weeks"][0][0]["level"] == 2 assert cache.warning_message is None @@ -242,6 +243,7 @@ def test_contribution_fetch_failure_sets_warning( db_session.refresh(cache) assert cache.status == "completed" + assert cache.result is not None assert cache.result["contribution_calendar"] is None assert cache.warning_message is not None diff --git a/frontend/src/components/forms/CareerFormEditors/ClientEditor.tsx b/frontend/src/components/forms/CareerFormEditors/ClientEditor.tsx index 3600cb23..5c5b1aa0 100644 --- a/frontend/src/components/forms/CareerFormEditors/ClientEditor.tsx +++ b/frontend/src/components/forms/CareerFormEditors/ClientEditor.tsx @@ -229,7 +229,7 @@ export function ClientEditor({ className="danger" onClick={() => onRemoveClient(expIndex, clientIndex)} > - 取引先を削除 + {client.is_vacation ? "休業を削除" : "取引先を削除"} );