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

connection pool issues

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 0.9.53
    • 0.9.54
    • Generic
    • None

    Description

      I'm having issues using connection pools. I've only managed to get them to work when the C code allocates the connection, either via creation of the pool object (where the connect options allocates all the available pool slots) or by adding connection options via set_config() and then using add_connection() with no arg. If I try to add a connection I've made in the python code it either fails with an error or I get a segfault. So, to be clear, here's what works and what doesn't:

      Works (all connections pre-allocated):

      pool = mariadb.ConnectionPool(
          pool_name = 'pool1',
          pool_size = 3,
          host = 'localhost',
          user = 'root',
          database = 'test',
          )
      

      Works (all connections added via internal connection):

      pool = mariadb.ConnectionPool(pool_name = 'pool1')
      pool.set_config(
              pool_size = 3,
              host = 'localhost',
              user = 'root',
              database = 'test',
              )
      for j in range(3):
          pool.add_connection()
      

      Fails with an error on the first add:

      pool = mariadb.ConnectionPool(
              pool_name = 'pool1',
              pool_size = 3,
              )
      for j in range(3):
          c = mariadb.connect(
              host = 'localhost',
              user = 'root',
              database = 'test',
              )
          pool.add_connection(c)
      

      => mariadb.PoolError: Couldn't get configuration for pool 'pool1'.

      This segfaults on the first add:

      pool = mariadb.ConnectionPool(pool_name = 'pool1')
      pool.set_config(pool_size = 3)
      for j in range(3):
          c = mariadb.connect(
              host = 'localhost',
              user = 'root',
              database = 'test',
              )
          pool.add_connection(c)
      

      Here's one more failure:

      def get_a_connection(pool):
          conn = None
          while not conn:
              try:
                  conn = pool.get_connection()
                  break
              except mariadb.PoolError as e:
                  pass
              try:
                  pool.add_connection()
              except mariadb.PoolError as e:
                  print(f"Pool is full: {e}")
                  break
       
          return conn
       
      pool = mariadb.ConnectionPool(pool_name = 'pool1')
       
      pool.set_config(
          pool_size = 3,
          host = 'localhost',
          user = 'root',
          database = 'test',
          )
      for j in range(3):
          conn = get_a_connection(pool)
      

      => first add_connection() fails with:
      => TypeError: 'sqlstate' is an invalid keyword argument for this function

      These tests were done with the latest pip3 install --pre mariadb code using python 3.6.9.

      Attachments

        Issue Links

          Activity

            People

              georg Georg Richter
              WayneD Wayne Davison (Inactive)
              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.