The following function is experiencing Deadlock when executing the second delete. Can…
- User
The following function is experiencing Deadlock when executing the second delete. Can you help me figure out why?
def clear_foapal_and_queue_items(position_id, pay_number, pay_year): query = """ select id from sub_queue_payroll where foapal_id in (select id from acct_foapal where position_id = :position_id and pay_number = :pay_number and year = :pay_year) and (submitted is not null or exists (select id from sub_submission where id = submission_id and status not in ('FAILED', 'PENDING', 'VALIDATED'))) """ if fetchone( query, {"position_id": position_id, "pay_number": pay_number, "pay_year": pay_year}, ): return False
codequery = """ delete from sub_queue_payroll where foapal_id in ( select id from acct_foapal where position_id = :position_id and pay_number = :pay_number and year = :pay_year) """ execute( query, {"position_id": position_id, "pay_number": pay_number, "pay_year": pay_year}, commit=False, ) query = """ delete from acct_foapal where position_id = :position_id and pay_number = :pay_number and year = :pay_year """ execute( query, {"position_id": position_id, "pay_number": pay_number, "pay_year": pay_year}, commit=False, ) commit() query = """ update sub_submission set status = 'PENDING', last_updated = sysdate, version = version + 1 where dept_code = (select department_code from org_position where id = :position_id) and pay_number = :pay_number and pay_year = :pay_year and status = 'VALIDATED' """ execute( query, {"position_id": position_id, "pay_number": pay_number, "pay_year": pay_year}, commit=True, ) return True - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.