Skip to content

Commit 880e649

Browse files
committed
Reset POOLS_HASH when reloading config to avoid duplications
Before, when configuration was reloaded, we checked whether a given pool configuration was changed by adding it to a HashSet and checking whether it was inserted or ignored. This behavior has a undesired effect when changing existing pools, as the new one will be added, even though the old will still exist in the HashSet. With this change, the HashSet is always recreated with current configuration, leaving intact the rest of the logic.
1 parent c38a4d3 commit 880e649

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/pool.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,11 @@ impl ConnectionPool {
160160
let mut address_id = 0;
161161

162162
let mut pools_hash = (*(*POOLS_HASH.load())).clone();
163+
let mut new_pools_hash = HashSet::<crate::config::Pool>::default();
163164

164165
for (pool_name, pool_config) in &config.pools {
165166
let changed = pools_hash.insert(pool_config.clone());
167+
new_pools_hash.insert(pool_config.clone());
166168

167169
// There is one pool per database/user pair.
168170
for user in pool_config.users.values() {
@@ -332,7 +334,7 @@ impl ConnectionPool {
332334
}
333335

334336
POOLS.store(Arc::new(new_pools.clone()));
335-
POOLS_HASH.store(Arc::new(pools_hash.clone()));
337+
POOLS_HASH.store(Arc::new(new_pools_hash.clone()));
336338

337339
Ok(())
338340
}

0 commit comments

Comments
 (0)