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

Add TASK_MANAGER_LOCK_TIMEOUT #15300

Merged

Conversation

TheRealHaoLiu
Copy link
Member

SUMMARY

TASK_MANAGER_LOCK_TIMEOUT controls the idle_in_transaction_session_timeout and idle_session_timeout DB connection setting for task manager connections and lock in database

hope to prevent the situation that the task instance that holds the lock becomes unresponsive and preventing other instance to be able to run task manager

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API
AWX VERSION

ADDITIONAL INFORMATION

@AlanCoding
Copy link
Member

Shouldn't this also apply to other locks like the periodic scheduler? A locked instance could still block any scheduled jobs from starting.

with django_pglocks_advisory_lock(*args, **kwargs) as internal_lock:
yield internal_lock
if lock_session_timeout_milliseconds > 0:
cur.execute(f"SET idle_in_transaction_session_timeout = {idle_in_transaction_session_timeout}")
Copy link
Member

Choose a reason for hiding this comment

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

in the case that we are closed, this will hit a InterfaceError: the cursor is closed error

in the case of task managers, we probably don't care because we are willing for the entire pid to go away, but if someone later on uses lock_session_timeout_milliseconds in another case there might be adverse affects

Copy link
Member

Choose a reason for hiding this comment

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

cursor has a closed property that we can condition off of

Copy link
Member Author

Choose a reason for hiding this comment

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

yah these 2 parts shouldnt have to shared a cursor... let me go ahead and use context manager for these 2 section of code

`TASK_MANAGER_LOCK_TIMEOUT` controls the `idle_in_transaction_session_timeout` and `idle_session_timeout` configuration for task manager connections and lock in database

hope to prevent the situation that the task instance that holds the lock becomes unresponsive and preventing other instance to be able to run task manager
@AlanCoding
Copy link
Member

Can we file a followup issue in https://github.com/Xof/django-pglocks?

This just seems really chatty and it's done on tasks running on 20 second intervals. An obvious action is to contribute this upstream to the library we're using and have it maintained there, but it might help to talk it out and ask if there should have been a better way to do this. Maybe some postgresql community could give some good feedback. Having this that works is a good starting place, but it would still be nice to iterate to make it better.

@TheRealHaoLiu TheRealHaoLiu merged commit 6f2307f into ansible:devel Jun 27, 2024
21 checks passed
@TheRealHaoLiu TheRealHaoLiu deleted the task-manager-session-timeout branch June 27, 2024 13:42
djyasin pushed a commit to djyasin/awx that referenced this pull request Sep 16, 2024
* Add TASK_MANAGER_LOCK_TIMEOUT

`TASK_MANAGER_LOCK_TIMEOUT` controls the `idle_in_transaction_session_timeout` and `idle_session_timeout` configuration for task manager connections and lock in database

hope to prevent the situation that the task instance that holds the lock becomes unresponsive and preventing other instance to be able to run task manager

* Add session timeout to periodic scheduler and all sub task manager locks
djyasin pushed a commit to djyasin/awx that referenced this pull request Nov 11, 2024
* Add TASK_MANAGER_LOCK_TIMEOUT

`TASK_MANAGER_LOCK_TIMEOUT` controls the `idle_in_transaction_session_timeout` and `idle_session_timeout` configuration for task manager connections and lock in database

hope to prevent the situation that the task instance that holds the lock becomes unresponsive and preventing other instance to be able to run task manager

* Add session timeout to periodic scheduler and all sub task manager locks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants