Skip to content

Commit f002725

Browse files
committed
store: Guard against a race when remapping shards
1 parent 004dfe2 commit f002725

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

store/postgres/src/connection_pool.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,10 +1440,16 @@ impl PoolCoordinator {
14401440
// version. Since dropping and recreating the foreign table
14411441
// definitions can slow the startup of other nodes down because of
14421442
// locking, we try to only do this when it is actually needed
1443-
for server in self.servers.iter() {
1444-
if pool.needs_remap(server)? {
1445-
pool.remap(server)?;
1446-
}
1443+
{
1444+
let mut conn = pool.get()?;
1445+
with_migration_lock(&mut conn, |_| {
1446+
for server in self.servers.iter() {
1447+
if pool.needs_remap(server)? {
1448+
pool.remap(server)?;
1449+
}
1450+
}
1451+
Ok(())
1452+
})?;
14471453
}
14481454

14491455
// pool had schema changes, refresh the import from pool into all

0 commit comments

Comments
 (0)