@@ -121,7 +121,6 @@ class Tenant(ha_base.ClusterProtocol):
121121 _pg_unavailable_msg : str | None
122122 _init_con_data : list [config .ConState ]
123123 _init_con_sql : bytes | None
124- _update_init_con_sql : bytes | None
125124
126125 _ha_master_serial : int
127126 _backend_adaptive_ha : adaptive_ha .AdaptiveHASupport | None
@@ -208,7 +207,7 @@ def __init__(
208207 self ._block_new_connections = set ()
209208 self ._report_config_data = {}
210209 self ._init_con_data = []
211- self ._init_con_sql = self . _update_init_con_sql = None
210+ self ._init_con_sql = None
212211
213212 # DB state will be initialized in init().
214213 self ._dbindex = None
@@ -731,7 +730,6 @@ def terminate_sys_pgcon(self) -> None:
731730 def set_init_con_data (self , data : list [config .ConState ]) -> None :
732731 self ._init_con_data = data
733732 self ._init_con_sql = None
734- self ._update_init_con_sql = None
735733 if data :
736734 self ._init_con_sql = self ._make_init_con_sql (data )
737735
@@ -1028,20 +1026,18 @@ async def acquire_pgcon(self, dbname: str) -> pgcon.PGConnection:
10281026 if not conn .is_healthy ():
10291027 logger .warning ("acquired an unhealthy pgcon; discard now" )
10301028 elif conn .last_init_con_data is not self ._init_con_data :
1031- if self ._update_init_con_sql :
1032- try :
1033- await conn .sql_execute (self ._update_init_con_sql )
1034- except Exception as e :
1035- logger .warning (
1036- "failed to update pgcon; discard now: %s" , e
1037- )
1038- else :
1039- conn .last_init_con_data = self ._init_con_data
1040- return conn
1041- else :
1029+ try :
1030+ await conn .sql_execute (
1031+ pgcon .RESET_STATIC_CFG_SCRIPT +
1032+ (self ._init_con_sql or b'' )
1033+ )
1034+ except Exception as e :
10421035 logger .warning (
1043- "don't know how to update pgcon; discard now"
1036+ "failed to update pgcon; discard now: %s" , e
10441037 )
1038+ else :
1039+ conn .last_init_con_data = self ._init_con_data
1040+ return conn
10451041 else :
10461042 return conn
10471043 self ._pg_pool .release (dbname , conn , discard = True )
@@ -1701,20 +1697,19 @@ async def load_config_file(self, compiler):
17011697 ]
17021698 + config_file_data
17031699 )
1704- return config_file_data
17051700
17061701 async def _reload_config_file (self ):
17071702 # Load TOML config file
17081703 compiler = self ._server .get_compiler_pool ()
1709- config_file_data = await self .load_config_file (compiler )
1710- self ._update_init_con_sql = b"""
1711- DELETE FROM _edgecon_state WHERE "type" = 'F';
1712- """ .strip () + self ._make_init_con_sql (config_file_data )
1704+ await self .load_config_file (compiler )
17131705
17141706 # Update sys pgcon and reload system config
17151707 async with self .use_sys_pgcon () as syscon :
17161708 if syscon .last_init_con_data is not self ._init_con_data :
1717- await syscon .sql_execute (self ._update_init_con_sql )
1709+ await syscon .sql_execute (
1710+ pgcon .RESET_STATIC_CFG_SCRIPT + (self ._init_con_sql or b'' )
1711+ )
1712+ syscon .last_init_con_data = self ._init_con_data
17181713 sys_config = await self ._load_sys_config (syscon = syscon )
17191714 # GOTCHA: don't notify the change of sysconfig because it's local
17201715 self ._dbindex .update_sys_config (sys_config )
0 commit comments