Skip to content

Commit 4315bff

Browse files
committed
fix: Require all nodes being shut down when mirroring the root inode
Except for the one that holds the root inode, of course.
1 parent 14b6851 commit 4315bff

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

mgmtd/src/grpc/buddy_group.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,32 @@ pub(crate) async fn mirror_root_inode(
267267
})?;
268268

269269
if clients > 0 {
270-
bail!("This operation requires that all clients are disconnected/unmounted, but still has {clients} clients mounted.");
270+
bail!(
271+
"This operation requires that all clients are disconnected/unmounted. \
272+
{clients} clients are still mounted."
273+
);
274+
}
275+
276+
let mut server_stmt = tx.prepare(sql!(
277+
"SELECT COUNT(*) FROM nodes
278+
WHERE node_type = ?1 AND UNIXEPOCH('now') - UNIXEPOCH(last_contact) < 180
279+
AND node_uid != ?2"
280+
))?;
281+
282+
let metas = server_stmt.query_row([NodeType::Meta.sql_variant(), node_uid], |row| {
283+
row.get::<_, i64>(0)
284+
})?;
285+
let storages = server_stmt
286+
.query_row([NodeType::Storage.sql_variant(), node_uid], |row| {
287+
row.get::<_, i64>(0)
288+
})?;
289+
290+
if metas > 0 || storages > 0 {
291+
bail!(
292+
"This operation requires that all nodes except the root meta node are shut \
293+
down. {metas} meta nodes (excluding the root meta node) and {storages} storage nodes have \
294+
communicated during the last 180s."
295+
);
271296
}
272297

273298
Ok(node_uid)

0 commit comments

Comments
 (0)