Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clp-package: Fix several search job cancellation issues: #425

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ async def handle_cancelling_search_jobs(db_conn_pool) -> None:
with contextlib.closing(db_conn_pool.connect()) as db_conn:
cancelling_jobs = fetch_cancelling_search_jobs(db_conn)

for job in cancelling_jobs:
job_id = job["job_id"]
for cancelling_job in cancelling_jobs:
job_id = str(cancelling_job["job_id"])
if job_id in active_jobs:
job = active_jobs.pop(job_id)
cancel_job_except_reducer(job)
Expand Down Expand Up @@ -459,7 +459,7 @@ async def check_job_status_and_update_db(db_conn_pool, results_cache_uri):
error_msg = f"Unexpected msg_type: {msg.msg_type.name}"
raise NotImplementedError(error_msg)

if set_job_status(db_conn, job_id, new_job_status, SearchJobStatus.RUNNING):
if set_job_status(db_conn, job_id, new_job_status):
kirkrodrigues marked this conversation as resolved.
Show resolved Hide resolved
if new_job_status == SearchJobStatus.SUCCEEDED:
logger.info(f"Completed job {job_id}.")
elif reducer_failed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ class SearchJobsDbManager {
await this.#sqlDbConnPool.query(
`UPDATE ${this.#searchJobsTableName}
SET ${SEARCH_JOBS_TABLE_COLUMN_NAMES.STATUS} = ${SEARCH_JOB_STATUS.CANCELLING}
WHERE ${SEARCH_JOBS_TABLE_COLUMN_NAMES.ID} = ?`,
WHERE ${SEARCH_JOBS_TABLE_COLUMN_NAMES.ID} = ?
AND ${SEARCH_JOBS_TABLE_COLUMN_NAMES.STATUS}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WHERE ${SEARCH_JOBS_TABLE_COLUMN_NAMES.ID} = ?
AND ${SEARCH_JOBS_TABLE_COLUMN_NAMES.STATUS}
WHERE ${SEARCH_JOBS_TABLE_COLUMN_NAMES.ID} = ?
AND ${SEARCH_JOBS_TABLE_COLUMN_NAMES.STATUS}

IN (${SEARCH_JOB_STATUS.PENDING}, ${SEARCH_JOB_STATUS.RUNNING})`,
jobId,
);
}
Expand Down
Loading