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?