@@ -33,7 +33,7 @@ import { HostSelector } from "./host_selector";
3333import { RandomHostSelector } from "./random_host_selector" ;
3434import { InternalPoolMapping } from "./utils/internal_pool_mapping" ;
3535import { RoundRobinHostSelector } from "./round_robin_host_selector" ;
36- import { AwsPoolClient } from "./aws_pool_client" ;
36+ import { AwsInternalPoolClient } from "./aws_pool_client" ;
3737import { AwsPoolConfig } from "./aws_pool_config" ;
3838import { LeastConnectionsHostSelector } from "./least_connections_host_selector" ;
3939import { PoolClientWrapper } from "./pool_client_wrapper" ;
@@ -59,7 +59,7 @@ export class InternalPooledConnectionProvider implements PooledConnectionProvide
5959 private readonly _poolMapping ?: InternalPoolMapping ;
6060 private readonly _poolConfig ?: AwsPoolConfig ;
6161 targetClient ?: ClientWrapper ;
62- internalPool : AwsPoolClient | undefined ;
62+ internalPool : AwsInternalPoolClient | undefined ;
6363
6464 private static poolExpirationCheckNanos : bigint = InternalPooledConnectionProvider . POOL_EXPIRATION_NANOS ; // 30 minutes
6565
@@ -80,6 +80,12 @@ export class InternalPooledConnectionProvider implements PooledConnectionProvide
8080 }
8181
8282 async connect ( hostInfo : HostInfo , pluginService : PluginService , props : Map < string , any > ) : Promise < ClientWrapper > {
83+ const resultProps = new Map ( props ) ;
84+ resultProps . set ( WrapperProperties . HOST . name , hostInfo . host ) ;
85+ if ( hostInfo . isPortSpecified ( ) ) {
86+ resultProps . set ( WrapperProperties . PORT . name , hostInfo . port ) ;
87+ }
88+
8389 let connectionHostInfo : HostInfo = hostInfo ;
8490 if (
8591 WrapperProperties . ENABLE_GREEN_HOST_REPLACEMENT . get ( props ) &&
@@ -96,6 +102,7 @@ export class InternalPooledConnectionProvider implements PooledConnectionProvide
96102 // Green instance DNS doesn't exist
97103
98104 const fixedHost : string = this . rdsUtil . removeGreenInstancePrefix ( hostInfo . host ) ;
105+ resultProps . set ( WrapperProperties . HOST . name , fixedHost ) ;
99106 connectionHostInfo = new HostInfoBuilder ( {
100107 hostAvailabilityStrategy : hostInfo . hostAvailabilityStrategy
101108 } )
@@ -106,9 +113,9 @@ export class InternalPooledConnectionProvider implements PooledConnectionProvide
106113 }
107114
108115 const dialect = pluginService . getDriverDialect ( ) ;
109- const preparedConfig = dialect . preparePoolClientProperties ( props , this . _poolConfig ) ;
116+ const preparedConfig = dialect . preparePoolClientProperties ( resultProps , this . _poolConfig ) ;
110117 this . internalPool = InternalPooledConnectionProvider . databasePools . computeIfAbsent (
111- new PoolKey ( connectionHostInfo . url , this . getPoolKey ( connectionHostInfo , props ) ) . getPoolKeyString ( ) ,
118+ new PoolKey ( connectionHostInfo . url , this . getPoolKey ( connectionHostInfo , resultProps ) ) . getPoolKeyString ( ) ,
112119 ( ) => dialect . getAwsPoolClient ( preparedConfig ) ,
113120 InternalPooledConnectionProvider . poolExpirationCheckNanos
114121 ) ;
@@ -123,6 +130,14 @@ export class InternalPooledConnectionProvider implements PooledConnectionProvide
123130 }
124131
125132 async releaseResources ( ) {
133+ if ( this . internalPool ) {
134+ try {
135+ await this . internalPool . releaseResources ( ) ;
136+ } catch ( error ) {
137+ // ignore
138+ }
139+ }
140+
126141 await InternalPooledConnectionProvider . databasePools . clear ( ) ;
127142 }
128143
0 commit comments