Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/sonic_ax_impl/mibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ def init_mgmt_interface_tables(db_conn):
:return: tuple of mgmt name to oid map and mgmt name to alias map
"""

db_conn.connect(CONFIG_DB)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connect

The expectation of SonicV2Connector is that connect to the same DB multiple time will be harmless and no resource leak. We need to dig deeper and check if the expectation is broken.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redis DB is not meant to handle too many connections ...there is a limit to number of connections. Each process should establish connection once in its life time and then use the same connection to do any queries ...any number of times. Too many connections request may result in hitting this error

db_conn.connect(STATE_DB)

mgmt_ports_keys = db_conn.keys(CONFIG_DB, mgmt_if_entry_table('*'))

if not mgmt_ports_keys:
Expand Down Expand Up @@ -378,14 +375,11 @@ def init_sync_d_lag_tables(db_conn):
# { lag_oid (SAI) -> lag_name (SONiC) }
sai_lag_map = {}

db_conn.connect(APPL_DB)

lag_entries = db_conn.keys(APPL_DB, "LAG_TABLE:*")

if not lag_entries:
return lag_name_if_name_map, if_name_lag_name_map, oid_lag_name_map, lag_sai_map, sai_lag_map

db_conn.connect(COUNTERS_DB)
lag_sai_map = db_conn.get_all(COUNTERS_DB, "COUNTERS_LAG_NAME_MAP")
for name, sai_id in lag_sai_map.items():
sai_id_key = get_sai_id_key(db_conn.namespace, sai_id.lstrip("oid:0x"))
Expand Down Expand Up @@ -471,7 +465,6 @@ def get_device_metadata(db_conn):
"""

DEVICE_METADATA = "DEVICE_METADATA|localhost"
db_conn.connect(db_conn.STATE_DB)

device_metadata = db_conn.get_all(db_conn.STATE_DB, DEVICE_METADATA)
return device_metadata
Expand Down Expand Up @@ -690,7 +683,6 @@ def dbs_get_bridge_port_map(dbs, db_name):
@staticmethod
def dbs_get_vlan_id_from_bvid(dbs, bvid):
for db_conn in Namespace.get_non_host_dbs(dbs):
db_conn.connect('ASIC_DB')
vlan_obj = db_conn.keys('ASIC_DB', "ASIC_STATE:SAI_OBJECT_TYPE_VLAN:" + bvid)
if vlan_obj is not None:
return port_util.get_vlan_id_from_bvid(db_conn, bvid)
Expand Down
10 changes: 1 addition & 9 deletions src/sonic_ax_impl/mibs/ieee802_1ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ def reinit_data(self):
"""
Subclass update data routine.
"""
# establish connection to application database.
Namespace.connect_all_dbs(self.db_conn, mibs.APPL_DB)
self.loc_chassis_data = Namespace.dbs_get_all(self.db_conn, mibs.APPL_DB, mibs.LOC_CHASSIS_TABLE)
if self.loc_chassis_data:
self.loc_chassis_data['lldp_loc_sys_cap_supported'] = parse_sys_capability(self.loc_chassis_data.get('lldp_loc_sys_cap_supported', ''))
Expand Down Expand Up @@ -155,8 +153,6 @@ def __init__(self):
super().__init__()

self.db_conn = Namespace.init_namespace_dbs()
# establish connection to application database.
Namespace.connect_all_dbs(self.db_conn, mibs.APPL_DB)
self.if_name_map = {}
self.if_alias_map = {}
self.if_id_map = {}
Expand Down Expand Up @@ -304,6 +300,7 @@ def __init__(self):
super().__init__()

self.db_conn = mibs.init_db()
self.db_conn.connect(mibs.APPL_DB)
self.loc_chassis_data = {}
self.man_addr_list = []
self.mgmt_ip_str = None
Expand All @@ -316,7 +313,6 @@ def reinit_data(self):
self.mgmt_ip_str = None

# establish connection to application database.
self.db_conn.connect(mibs.APPL_DB)
mgmt_ip_bytes = self.db_conn.get(mibs.APPL_DB, mibs.LOC_CHASSIS_TABLE, 'lldp_loc_man_addr')

if not mgmt_ip_bytes:
Expand Down Expand Up @@ -506,7 +502,6 @@ def __init__(self):

self.db_conn = Namespace.init_namespace_dbs()
# establish connection to application database.
Namespace.connect_all_dbs(self.db_conn, mibs.APPL_DB)
self.if_range = []
self.oid_name_map = {}
self.mgmt_oid_name_map = {}
Expand Down Expand Up @@ -582,9 +577,6 @@ def reinit_data(self):

self.oid_name_map.update(self.mgmt_oid_name_map)

# establish connection to application database.
Namespace.connect_all_dbs(self.db_conn, mibs.APPL_DB)

self.if_range = []
for if_oid, if_name in self.oid_name_map.items():
self.update_rem_if_mgmt(if_oid, if_name)
Expand Down
3 changes: 1 addition & 2 deletions src/sonic_ax_impl/mibs/ietf/rfc1213.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def __init__(self):
self.neigh_key_list = {}

def reinit_data(self):
Namespace.connect_all_dbs(self.db_conn, mibs.APPL_DB)
self.neigh_key_list = Namespace.dbs_keys_namespace(self.db_conn, mibs.APPL_DB, "NEIGH_TABLE:*")

def _update_from_arptable(self):
Expand Down Expand Up @@ -711,9 +710,9 @@ def __init__(self):
super().__init__()
self.db_conn = mibs.init_db()
self.hostname = socket.gethostname()
self.db_conn.connect(self.db_conn.CONFIG_DB)

def reinit_data(self):
self.db_conn.connect(self.db_conn.CONFIG_DB)
device_metadata = self.db_conn.get_all(self.db_conn.CONFIG_DB, "DEVICE_METADATA|localhost")

if device_metadata and device_metadata.get('hostname'):
Expand Down
1 change: 0 additions & 1 deletion src/sonic_ax_impl/mibs/ietf/rfc2737.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def __init__(self):
super().__init__()

self.statedb = Namespace.init_namespace_dbs()
Namespace.connect_all_dbs(self.statedb, mibs.STATE_DB)

# List of available sub OIDs.
self.physical_entities = []
Expand Down
1 change: 0 additions & 1 deletion src/sonic_ax_impl/mibs/ietf/rfc3433.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ def __init__(self):
super().__init__()

self.statedb = Namespace.init_namespace_dbs()
Namespace.connect_all_dbs(self.statedb, mibs.STATE_DB)

# list of available sub OIDs
self.sub_ids = []
Expand Down
1 change: 0 additions & 1 deletion src/sonic_ax_impl/mibs/vendor/cisco/bgp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def __init__(self):
self.session_status_list = []

def reinit_data(self):
Namespace.connect_all_dbs(self.db_conn, mibs.STATE_DB)
self.neigh_state_map = Namespace.dbs_keys_namespace(self.db_conn, mibs.STATE_DB, "NEIGH_STATE_TABLE|*")

def update_data(self):
Expand Down