mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Send QUIT to worker before dying (#14913)
Fix deadlock scenario where dispatcher child process stuck in reading from queue loop after dispatcher parent process decided to quit Co-authored-by: Alan Rominger <arominge@redhat.com>
This commit is contained in:
@@ -259,6 +259,12 @@ class AWXConsumerPG(AWXConsumerBase):
|
|||||||
current_downtime = time.time() - self.pg_down_time
|
current_downtime = time.time() - self.pg_down_time
|
||||||
if current_downtime > self.pg_max_wait:
|
if current_downtime > self.pg_max_wait:
|
||||||
logger.exception(f"Postgres event consumer has not recovered in {current_downtime} s, exiting")
|
logger.exception(f"Postgres event consumer has not recovered in {current_downtime} s, exiting")
|
||||||
|
# Sending QUIT to multiprocess queue to signal workers to exit
|
||||||
|
for worker in self.pool.workers:
|
||||||
|
try:
|
||||||
|
worker.quit()
|
||||||
|
except Exception:
|
||||||
|
logger.exception(f"Error sending QUIT to worker {worker}")
|
||||||
raise
|
raise
|
||||||
# Wait for a second before next attempt, but still listen for any shutdown signals
|
# Wait for a second before next attempt, but still listen for any shutdown signals
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
@@ -270,6 +276,12 @@ class AWXConsumerPG(AWXConsumerBase):
|
|||||||
except Exception:
|
except Exception:
|
||||||
# Log unanticipated exception in addition to writing to stderr to get timestamps and other metadata
|
# Log unanticipated exception in addition to writing to stderr to get timestamps and other metadata
|
||||||
logger.exception('Encountered unhandled error in dispatcher main loop')
|
logger.exception('Encountered unhandled error in dispatcher main loop')
|
||||||
|
# Sending QUIT to multiprocess queue to signal workers to exit
|
||||||
|
for worker in self.pool.workers:
|
||||||
|
try:
|
||||||
|
worker.quit()
|
||||||
|
except Exception:
|
||||||
|
logger.exception(f"Error sending QUIT to worker {worker}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user