community.postgresql
community.postgresql copied to clipboard
postgresql_ext does not support async
SUMMARY
The community.postgresql.postgresql_ext
module doesn't appear to support async
. I have a task that installs many extensions on many databases which by default runs really slow so I thought it would benefit me to use async
.
This was originally brought up here and was told it would be worth raising an issue here.
ISSUE TYPE
- Bug Report
COMPONENT NAME
community.postgresql.postgresql_ext
ANSIBLE VERSION
ansible [core 2.11.8]
config file = /home/carey/projects/infrastructure_configuration/ansible.cfg
configured module search path = ['/home/<omitted>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/<omitted>/.local/lib/python3.8/site-packages/ansible
ansible collection location = /home/<omitted>/.ansible/collections:/usr/share/ansible/collections
executable location = /home/<omitted>/.local/bin/ansible
python version = 3.8.12 (default, Jan 15 2022, 18:39:47) [GCC 7.5.0]
jinja version = 3.0.3
libyaml = False
COLLECTION VERSION
Collection Version
-------------------- -------
community.postgresql 1.6.0
CONFIGURATION
ANSIBLE_FORCE_COLOR = True
ANSIBLE_NOCOWS = True
ANSIBLE_PIPELINING = True
DEFAULT_ACTION_PLUGIN_PATH = ['/usr/share/ansible_plugins/action_plugins']
DEFAULT_ASK_PASS = False
DEFAULT_CALLBACK_PLUGIN_PATH = ['/usr/share/ansible_plugins/callback_plugins']
DEFAULT_CONNECTION_PLUGIN_PATH = ['/usr/share/ansible_plugins/connection_plugins']
DEFAULT_FILTER_PLUGIN_PATH = ['/usr/share/ansible_plugins/filter_plugins']
DEFAULT_FORKS = 20
DEFAULT_GATHERING = implicit
DEFAULT_LOOKUP_PLUGIN_PATH = ['/usr/share/ansible_plugins/lookup_plugins']
DEFAULT_MANAGED_STR = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
DEFAULT_POLL_INTERVAL = 15
DEFAULT_REMOTE_PORT = 22
DEFAULT_TIMEOUT = 30
DEFAULT_TRANSPORT = smart
DEFAULT_VARS_PLUGIN_PATH = ['/usr/share/ansible_plugins/vars_plugins']
HOST_KEY_CHECKING = False
RETRY_FILES_ENABLED = False
OS / ENVIRONMENT
Ubuntu 18.04 (ansible host) Ubuntu 20.04 (target remote host)
STEPS TO REPRODUCE
- name: "install postgresql extensions"
postgresql_ext:
db: "{{ item[0] }}"
name: "{{ item[1] }}"
with_nested:
- "{{ test_database_list }}"
- - pageinspect
- pg_buffercache
- pg_freespacemap
- pg_prewarm
- pg_stat_statements
- pg_visibility
- pg_trgm
- pgrowlocks
- pgstattuple
become_user: postgres
async: 30
poll: 0
EXPECTED RESULTS
async works as expected when using poll:0 resulting in the task "firing and forgeting"
ACTUAL RESULTS
The task takes longer to run than without async/poll used. Using async_status module results in could not find job
error.
Complete task code and result can be found here: https://gist.github.com/astrumas/87e54453d4a1021092e300fd9c6361b9
@astrumas hello, thank you for the PR!
The async
feature is a core one. In other words, it's implemented not on the module's level (we can't make the modules supporting this, it is supported by Ansible in general).
-
Have you tried to ask the question in the
#users:ansible.im
matrix channel? How to join, see the communication guide. I'm not really strong at a user. @hunleyd @tcraxs @kostiantyn-nemchenko @MichaelDBA maybe you have experience in usingasync
with c.postgresql? -
Can it be something on the postgresql side? Have you examined its log files for errors after running the task?
@astrumas hello, thank you for the PR!
The
async
feature is a core one. In other words, it's implemented not on the module's level (we can't make the modules supporting this, it is supported by Ansible in general).
- Have you tried to ask the question in the
#users:ansible.im
matrix channel? How to join, see the communication guide. I'm not really strong at a user. @hunleyd @tcraxs @kostiantyn-nemchenko @MichaelDBA maybe you have experience in usingasync
with c.postgresql?- Can it be something on the postgresql side? Have you examined its log files for errors after running the task?
Thanks for your reply and your suggestions
I haven't found anything on the postgres side, but I did try changing the task down to one database and one extension using async
and the async_status
module still returned an error that the job didn't exist. To my understanding I think that means async
is not supported by the module, as it should return that it was completed or that the job existed. This is the first time I have used async
, so my understanding could be incorrect.
Ill look into joining the channel and asking there, in the meantime I hope one of your colleagues has used async
before with the postgresql modules.
Seems nobody has the experience.
@astrumas whatever you'll find, please let us know the result here
Hi, @astrumas.
Is this still an issue for you? I've run the suggested repro and am able to use async
with poll
successfully with ansible [core 2.12.5]
The playbook I used: issue_198.txt
The output file with async
and poll
on:
async_on.txt
The output file with async
and poll
off:
async_off.txt
The async_on.txt
file shows successful output as well as both ansible_job_id
and ansible_async
results file.
The async_off.txt
file shows all tasks successful except the ansible.builtin.async_status:
task, but this is expected since async
is off for this run.
Kindly let me know? We'll be happy to close this issue out for you insofar as it's no longer occurring.
Thanks!
@jchancojr I will be revisiting it this week and will let you know!
@astrumas Perfect. Looking forward to your results.
Also, nice to talk to you again ;)
Hi, @astrumas
Just reaching out to see if you've had time to revisit this. No sweat if not. Kindly let me know? Thanks!
@jchancojr Nice to talk to you again as well!! I apologize, priorities got shifted and I was unable to visit it when I had initially planned to. You will hear back from me this week on this.
@jchancojr I upgraded to ansible-core 2.12.5 (from 2.11), which also upgraded the community.postgresql collection to 1.7.4 and I am still experiencing this issue.
I copied and used your tasks from your playbook example. I have also included task profiling so you can see how much slower it is with async on versus off.
astrumas_198_playbook_async_off.txt astrumas_198_playbook_async_on.txt astrumas_198_async_off.txt astrumas_198_async_on.txt
hi Carey!
community.postgresql collection to 1.7.4
Can you try w/ 2.1.5 ? Just trying to see if it's an issue w/ the backport version or not. Thanks!
Can you try w/ 2.1.5 ? Just trying to see if it's an issue w/ the backport version or not. Thanks!
@astrumas you can get the latest version with
ansible-galaxy collection install community.postgresql
UPDATE: Though i think this all relates to the ansible core https://github.com/ansible-collections/community.postgresql/issues/198#issuecomment-1049627090