You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Performance issue with many groups, too many SQL queries #4461
Can you run awx-manage profile_sql on the command line and re-run the job? After doing that, check the logs and see if it shows the flood of group-specific SQL which you anticipated. Ping @ryanpetrello that I got those instructions right.
Thanks I would like to reproduce this on my machine.
Are you running AWX 6.1.0 or an earlier version?
What are the general metrics of your inventory? Was it imported from a cloud source? Is it a smart inventory? What is the approximate number of groups? Ballpark, what fraction of them are populated with hosts, and are a lot of groups children of other groups?
@ryanpetrello I've tried to test but I couldn't make it work.
Pulled master and then used ansible-playbook -i inventory install.yml with these commented out:
--- a/installer/inventory+++ b/installer/inventory@@ -6,8 +6,8 @@# Remove these lines if you want to run a local image build
# Otherwise the setup playbook will install the official Ansible images. Versions may
# be selected based on: latest, 1, 1.0, 1.0.0, 1.0.0.123
# by default the base will be used to search for ansible/awx_web and ansible/awx_task
-dockerhub_base=ansible-dockerhub_version=6.1.0+#dockerhub_base=ansible+#dockerhub_version=6.1.0
The result was this strange error in the Job output:
@ryanpetrello I got it working. I thought the awx_task container would reset if I edit the files in it, but they are persistent, in fact, so a restart allowed me to test.
With query logging enabled the wait was reduced from 60 seconds to 15-20 seconds, before any text is printed in the output pane. So that looks decent, thank you.
I could still log 900 DB queries in between starting the job and when the fitst output is printed.
I could still log 900 DB queries in between starting the job and when the fitst output is printed.
I would expect less than 200 from numbers I had from #3883... or at least less than 300 including the sync.
If this is due to the cancel callback, then there's nothing we can do about that. It is expected that a job will regularly check the database for a signal from the user to cancel. If there are repetitive queries being shown other than that, then I would like to have a look.
Tried this out....there is still definitely a delay, but it is under 30 seconds. Would like to reproduce original bug (tried out on current devel that has fix). Also not quite sure how to get the postgres logs in the development environment. Will catch up with you about this @ryanpetrello
Activity
AlanCoding commentedon Aug 13, 2019
That linked issue should not apply for groups.
Can you run
awx-manage profile_sqlon the command line and re-run the job? After doing that, check the logs and see if it shows the flood of group-specific SQL which you anticipated. Ping @ryanpetrello that I got those instructions right.towolf commentedon Aug 13, 2019
Ok then, I ran this command in the awx_task container:
But here it states, that it enables "slowlog" for queries that take longer than 2 seconds.
What I observed, were ten thousand queries fired in rapid succession.
So this output is useless I'm afraid. I'll paste the query log from Postgres itself below.
towolf commentedon Aug 13, 2019
Postgres log:
Note this is 11 thousand queries from one job only ...
towolf commentedon Aug 13, 2019
AlanCoding commentedon Aug 13, 2019
Thanks I would like to reproduce this on my machine.
Are you running AWX 6.1.0 or an earlier version?
What are the general metrics of your inventory? Was it imported from a cloud source? Is it a smart inventory? What is the approximate number of groups? Ballpark, what fraction of them are populated with hosts, and are a lot of groups children of other groups?
towolf commentedon Aug 13, 2019
6.1.0, latest greatest!
Groups:

Hosts:

Le0exxx commentedon Aug 14, 2019
We hit the same issue, when there is 236 groups for the inventory update.
ryanpetrello commentedon Aug 14, 2019
I'm able to reproduce this:
optimize a slow query in inventory script generation
ryanpetrello commentedon Aug 14, 2019
@towolf @Le0exxx you mind giving this change a try and seeing if performance improves for you?
#4487
towolf commentedon Aug 15, 2019
@ryanpetrello I've tried to test but I couldn't make it work.
Pulled master and then used
ansible-playbook -i inventory install.ymlwith these commented out:The result was this strange error in the Job output:
towolf commentedon Aug 15, 2019
Do you have an easier way to test this change?
ryanpetrello commentedon Aug 15, 2019
@towolf that failure looks unrelated to this issue/PR. You might have better luck just installing 6.1.0 and applying this diff manually:
https://github.com/ansible/awx/pull/4487/files
It's just a single line and you should see what you need in
/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/towolf commentedon Aug 16, 2019
@ryanpetrello I got it working. I thought the awx_task container would reset if I edit the files in it, but they are persistent, in fact, so a restart allowed me to test.
With query logging enabled the wait was reduced from 60 seconds to 15-20 seconds, before any text is printed in the output pane. So that looks decent, thank you.
I could still log 900 DB queries in between starting the job and when the fitst output is printed.
But those
SELECT main_group.idqueries are gone.AlanCoding commentedon Aug 16, 2019
I would expect less than 200 from numbers I had from #3883... or at least less than 300 including the sync.
If this is due to the cancel callback, then there's nothing we can do about that. It is expected that a job will regularly check the database for a signal from the user to cancel. If there are repetitive queries being shown other than that, then I would like to have a look.
kdelee commentedon Sep 12, 2019
Tried this out....there is still definitely a delay, but it is under 30 seconds. Would like to reproduce original bug (tried out on current devel that has fix). Also not quite sure how to get the postgres logs in the development environment. Will catch up with you about this @ryanpetrello
kdelee commentedon Sep 19, 2019
Tried out again with #4461 (comment) , still works for me, still seeing the more reasonable delay. Going to close. Thanks!