Skip to content

postgresql_info not closing connection to database #465

@phemmer

Description

@phemmer
SUMMARY

When using the postgresql_info module, it doesn't close the connection to the database. Normally this isn't an issue as the process exits and the connection is terminated that way. However when using mitogen the process does not exit and the connection remains. In my case, it's connecting to the template1 database, and on a subsequent task when I try to call postgresql_database to create a database, it fails with source database "template1" is being accessed by other users.

I'm not sure what the thoughts are regarding mitogen, and whether this should be considered a bug on their side, or here.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

postgresql_info

ANSIBLE VERSION
ansible [core 2.14.4]
  config file = None
  configured module search path = ['/home/phemmer/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/phemmer/.local/lib/python3.11/site-packages/ansible
  ansible collection location = /home/phemmer/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/phemmer/.local/bin/ansible
  python version = 3.11.2 (main, Feb  8 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection           Version
-------------------- -------
community.postgresql 2.4.0  
CONFIGURATION
CONFIG_FILE() = /home/phemmer/git/ht/edge/ansible/ht/ansible.cfg
DEFAULT_STRATEGY(/home/phemmer/git/ht/edge/ansible/ht/ansible.cfg) = mitogen_linear
DEFAULT_STRATEGY_PLUGIN_PATH(/home/phemmer/git/ht/edge/ansible/ht/ansible.cfg) = ['/home/phemmer/git/mitogen/ansible_mitogen/plugins/strategy']
HOST_KEY_CHECKING(/home/phemmer/git/ht/edge/ansible/ht/ansible.cfg) = False
OS / ENVIRONMENT

Mitogen 330375b
PostgreSQL 15
Debian 11

STEPS TO REPRODUCE
- hosts:
    - myhost
  tasks:
    - postgresql_info:
      become_user: postgres
    - postgresql_db:
        name: test
      become_user: postgres
EXPECTED RESULTS

database created

ACTUAL RESULTS
TASK [postgresql_db] ****************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: DETAIL:  There is 1 other session using the database.
fatal: [myhost]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "msg": "Database query failed: source database \"template1\" is being accessed by other users\nDETAIL:  There is 1 other session using the database.\n"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions