mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 09:07:45 -02:30
Apply conservative database connection reduction changes (#14066)
This is expected to free up 4 additional database connections per traditional node compare to roughly 12 in total before this change Out of these 3 are accomplished by using existing connection for recently added services then 1 is obtained by closing the connection for the idle callback receiver main process Signed-off-by: jessicamack <jmack@redhat.com> Co-authored-by: jessicamack <jmack@redhat.com>
This commit is contained in:
@@ -143,9 +143,10 @@ class AWXConsumerRedis(AWXConsumerBase):
|
|||||||
def run(self, *args, **kwargs):
|
def run(self, *args, **kwargs):
|
||||||
super(AWXConsumerRedis, self).run(*args, **kwargs)
|
super(AWXConsumerRedis, self).run(*args, **kwargs)
|
||||||
self.worker.on_start()
|
self.worker.on_start()
|
||||||
|
logger.info(f'Callback receiver started with pid={os.getpid()}')
|
||||||
|
db.connection.close() # logs use database, so close connection
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
logger.debug(f'{os.getpid()} is alive')
|
|
||||||
time.sleep(60)
|
time.sleep(60)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import logging
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
|
|
||||||
from awx.main.dispatch import pg_bus_conn
|
from awx.main.dispatch import pg_bus_conn
|
||||||
from awx.main.dispatch.worker.task import TaskWorker
|
from awx.main.dispatch.worker.task import TaskWorker
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
def handle(self, *arg, **options):
|
def handle(self, *arg, **options):
|
||||||
try:
|
try:
|
||||||
with pg_bus_conn(new_connection=True) as conn:
|
with pg_bus_conn() as conn:
|
||||||
conn.listen("tower_settings_change")
|
conn.listen("tower_settings_change")
|
||||||
for e in conn.events(yield_timeouts=True):
|
for e in conn.events(yield_timeouts=True):
|
||||||
if e is not None:
|
if e is not None:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
def handle(self, *arg, **options):
|
def handle(self, *arg, **options):
|
||||||
try:
|
try:
|
||||||
with pg_bus_conn(new_connection=True) as conn:
|
with pg_bus_conn() as conn:
|
||||||
conn.listen("rsyslog_configurer")
|
conn.listen("rsyslog_configurer")
|
||||||
# reconfigure rsyslog on start up
|
# reconfigure rsyslog on start up
|
||||||
reconfigure_rsyslog()
|
reconfigure_rsyslog()
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class Command(BaseCommand):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def do_hearbeat_loop(self):
|
def do_hearbeat_loop(self):
|
||||||
with pg_bus_conn(new_connection=True) as conn:
|
|
||||||
while True:
|
while True:
|
||||||
|
with pg_bus_conn() as conn:
|
||||||
logger.debug('Sending heartbeat')
|
logger.debug('Sending heartbeat')
|
||||||
conn.notify('web_ws_heartbeat', self.construct_payload())
|
conn.notify('web_ws_heartbeat', self.construct_payload())
|
||||||
time.sleep(settings.BROADCAST_WEBSOCKET_BEACON_FROM_WEB_RATE_SECONDS)
|
time.sleep(settings.BROADCAST_WEBSOCKET_BEACON_FROM_WEB_RATE_SECONDS)
|
||||||
|
|||||||
Reference in New Issue
Block a user