Uploaded image for project: 'MariaDB Connector/Python'
  1. MariaDB Connector/Python
  2. CONPY-255

ConnectionPool.get_connection does not raise mariadb.PoolError

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 1.1.5, 1.1.6
    • 1.1.7
    • Connection Pooling
    • None
    • Win10 21H2, MariaDB Server 10.6.11 (official docker image)
    • 3.10.4

    Description

      Steps to reproduce

      1. set enviroment variables to allow login to server (see attached file)
      2. Run python example

      The example code initializes a ConnectionPool with 3 connections and calls get_connection() 4 times.

      Expected outcome

      As the documentation says, get_connection should raise a PoolError, because no connection is available:

      ConnectionPool.get_connection()
      Returns a connection from the connection pool or raises a PoolError exception if a connection is not available.

      Actual outcome

      get_connection() does not raise PoolError but returns None

      Workaround

      Do not catch PoolError but test return value:

       
      conn = pool.get_connection()
      if not conn:
          # put error handling here
      

      Remarks

      There is probably much code which relies on the current implementation, so its probably better to change the documentation.

      There is a test case test_connection_pool_maxconn in .\testing\test\integration\test_pooling.py but it does not assert that a PoolError is raised.

      Attachments

        Activity

          gmech G.Mech created issue -
          gmech G.Mech made changes -
          Field Original Value New Value
          Description h2. Steps to reproduce

          # set enviroment variables to allow login to server (see attached file)
          # Run python example

          The example code initializes a {{ConnectionPool}} with 3 connections and calls {{get_connection()}} 4 times.

          h2. Expected outcome

          As the the [documentation|https://mariadb-corporation.github.io/mariadb-connector-python/pool.html#mariadb.ConnectionPool.get_connection] says, {{get_connection}} should raise a {{PoolError}}, because no connection is available:

          {quote}ConnectionPool.get_connection()
          Returns a connection from the connection pool or raises a PoolError exception if a connection is not available.{quote}

          h2. Actual outcome

          {{get_connection()}} does not raise {{PoolError}} but returns {{None}}

          h2. Workaround

          Do not catch {{PoolError}} but test return value:

          {code:python}

          conn = pool.get_connection()
          if not conn:
              # put error handling here
          {code}

          h2. Remarks

          There is probably much code which relies on the current implementation, so its probably better to change the documentation.

          There is a test case{{test_connection_pool_maxconn}} in {{.\testing\test\integration\test_pooling.py}} but it does not assert that a {{PoolError}} is raised.
          h2. Steps to reproduce

          # set enviroment variables to allow login to server (see attached file)
          # Run python example

          The example code initializes a {{ConnectionPool}} with 3 connections and calls {{get_connection()}} 4 times.

          h2. Expected outcome

          As the [documentation|https://mariadb-corporation.github.io/mariadb-connector-python/pool.html#mariadb.ConnectionPool.get_connection] says, {{get_connection}} should raise a {{PoolError}}, because no connection is available:

          {quote}ConnectionPool.get_connection()
          Returns a connection from the connection pool or raises a PoolError exception if a connection is not available.{quote}

          h2. Actual outcome

          {{get_connection()}} does not raise {{PoolError}} but returns {{None}}

          h2. Workaround

          Do not catch {{PoolError}} but test return value:

          {code:python}

          conn = pool.get_connection()
          if not conn:
              # put error handling here
          {code}

          h2. Remarks

          There is probably much code which relies on the current implementation, so its probably better to change the documentation.

          There is a test case{{test_connection_pool_maxconn}} in {{.\testing\test\integration\test_pooling.py}} but it does not assert that a {{PoolError}} is raised.
          gmech G.Mech made changes -
          Description h2. Steps to reproduce

          # set enviroment variables to allow login to server (see attached file)
          # Run python example

          The example code initializes a {{ConnectionPool}} with 3 connections and calls {{get_connection()}} 4 times.

          h2. Expected outcome

          As the [documentation|https://mariadb-corporation.github.io/mariadb-connector-python/pool.html#mariadb.ConnectionPool.get_connection] says, {{get_connection}} should raise a {{PoolError}}, because no connection is available:

          {quote}ConnectionPool.get_connection()
          Returns a connection from the connection pool or raises a PoolError exception if a connection is not available.{quote}

          h2. Actual outcome

          {{get_connection()}} does not raise {{PoolError}} but returns {{None}}

          h2. Workaround

          Do not catch {{PoolError}} but test return value:

          {code:python}

          conn = pool.get_connection()
          if not conn:
              # put error handling here
          {code}

          h2. Remarks

          There is probably much code which relies on the current implementation, so its probably better to change the documentation.

          There is a test case{{test_connection_pool_maxconn}} in {{.\testing\test\integration\test_pooling.py}} but it does not assert that a {{PoolError}} is raised.
          h2. Steps to reproduce

          # set enviroment variables to allow login to server (see attached file)
          # Run python example

          The example code initializes a {{ConnectionPool}} with 3 connections and calls {{get_connection()}} 4 times.

          h2. Expected outcome

          As the [documentation|https://mariadb-corporation.github.io/mariadb-connector-python/pool.html#mariadb.ConnectionPool.get_connection] says, {{get_connection}} should raise a {{PoolError}}, because no connection is available:

          {quote}ConnectionPool.get_connection()
          Returns a connection from the connection pool or raises a PoolError exception if a connection is not available.{quote}

          h2. Actual outcome

          {{get_connection()}} does not raise {{PoolError}} but returns {{None}}

          h2. Workaround

          Do not catch {{PoolError}} but test return value:

          {code:python}

          conn = pool.get_connection()
          if not conn:
              # put error handling here
          {code}

          h2. Remarks

          There is probably much code which relies on the current implementation, so its probably better to change the documentation.

          There is a test case {{test_connection_pool_maxconn}} in {{.\testing\test\integration\test_pooling.py}} but it does not assert that a {{PoolError}} is raised.
          georg Georg Richter made changes -
          Fix Version/s 1.1.7 [ 28707 ]
          georg Georg Richter made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]

          People

            georg Georg Richter
            gmech G.Mech
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.