0

I have a python file with MySQL setup like below.


import mysql.connector.pooling
import logging
from utils.helper_funcs import create_log, get_retry_count, get_default_sleep_time
import time


class DBConnection():
    """create a mysql connection pool"""
    pool = None
    connection = None
    cusror = None

    def create_pool(self, pool_name="testpool"):
      self.pool = mysql.connector.pooling.MySQLConnectionPool(
          pool_name=pool_name,
          pool_reset_session=True,
          **self.dbconfig)

    def open_thread(self):
      """Open connection """   
      if (self.pool is not None) and (self.connection is None):
        self.connection = self.pool.get_connection()
        self.cursor = self.connection.cursor()

    def close(self):
        if self.connection is not None:
          self.cursor.close()
          self.connection.close()
          self.connection = None

con = DBConnection()

I have 5 docker containers, two containers with huge traffic every 6 hours. these are working fine. But in other containers, I am getting

2055: Lost connection to MySQL server at 'xxxxxxx:xxxx', system error: 32 Broken pipe

I have the default pool_size=5. closing the connection con.close() after all the crud operations. This pool size 5 can be independent across docker containers? what will be the reason for the above error? any suggestions?

Spring
  • 588
  • 1
  • 5
  • 20
  • It looks to me that you have some kind of network problem or connection timeout. I'm also assuming that you have the above app script for each container, if so, you have an independent pool connection for each container. I can point you to this for debug the problem: https://stackoverflow.com/questions/49622416/interfaceerror-2013-lost-connection-to-mysql-server-during-query – Nuno Mariz Nov 23 '21 at 09:44

0 Answers0