Skip to content

Commit f0d0ed7

Browse files
committed
more review fixes
1 parent 20787fc commit f0d0ed7

3 files changed

Lines changed: 29 additions & 16 deletions

File tree

nexus/src/app/background/tasks/trust_quorum.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,10 @@ async fn drive_reconfiguration(
251251
}
252252

253253
// For each unacked node, need to send a `Commit` or `PrepareAndCommit'
254-
if config.state.is_committing() {
255-
return commit(log, opctx, datastore, config).await;
256-
}
257-
258-
Ok(Status::ConfigInactive)
254+
//
255+
// At this point we know that the configuration is active and we are not
256+
// preparing. Therefore we must be committing.
257+
commit(log, opctx, datastore, config).await
259258
}
260259

261260
async fn prepare(
@@ -347,6 +346,13 @@ async fn commit(
347346
}
348347
}
349348

349+
if ops.is_empty() {
350+
bail!(
351+
"Unexpected error. No members to commit, \
352+
even though configuration was active."
353+
);
354+
}
355+
350356
//
351357
// Get a set of random clients. We can proxy requests if these clients are
352358
// different from the members that need committing.
@@ -395,7 +401,7 @@ async fn commit(
395401
let ops_per_client = ops.len() / clients.len();
396402
let num_clients = clients.len();
397403
let mut client_destinations_by_worker_task_id = BTreeMap::new();
398-
for (i, client) in clients.into_iter().enumerate() {
404+
for (i, (client_dest, client)) in clients.into_iter().enumerate() {
399405
let config = config.clone();
400406
let client_ops = if i + 1 == num_clients {
401407
// Take all remaining ops for the last client.
@@ -406,9 +412,9 @@ async fn commit(
406412
// always drain from the front.
407413
ops.drain(..ops_per_client).collect()
408414
};
409-
let client_dest = client.0.clone();
415+
let client_dest2 = client_dest.clone();
410416
let handle = workers.spawn(async move {
411-
run_commit_ops(client.0, client.1, client_ops, config).await
417+
run_commit_ops(client_dest2, client, client_ops, config).await
412418
});
413419
client_destinations_by_worker_task_id.insert(handle.id(), client_dest);
414420
}

nexus/src/app/trust_quorum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl super::Nexus {
8080
the abort to the database also failed with error: {e}. \
8181
Abort will have to be performed explicitly by the \
8282
operator.",
83-
msg.clone()
83+
msg
8484
))
8585
})?;
8686

@@ -137,7 +137,7 @@ impl super::Nexus {
137137
if !intersection.is_empty() {
138138
return Err(Error::invalid_request(format!(
139139
"The following sleds are already members of the trust quorum: \
140-
{intersection:?}. Is there a problem with their sled agents?"
140+
{intersection:?}."
141141
)));
142142
}
143143

nexus/types/src/external_api/views.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -637,15 +637,22 @@ pub struct RackMembershipChange {
637637

638638
impl From<TrustQuorumConfig> for RackMembershipChange {
639639
fn from(value: TrustQuorumConfig) -> Self {
640+
// `Unacked` means that a member has not received and acked a `Prepare`
641+
// yet. `Prepared` means that a member has acknolwedged the prepare but
642+
// not the commit. `Committed` is when the member starts participating
643+
// in the new group.
644+
//
645+
// Since we don't want to expose trust quorum specific knowledge to
646+
// the operator, and they really only want to know when the membership
647+
// change has started to take effect, we say that any member that hasn't
648+
// yet committed is unacknowledged.
640649
let unacknowledged_members = value
641650
.members
642651
.iter()
643-
.filter_map(|(id, data)| {
644-
if data.state == TrustQuorumMemberState::Committed {
645-
Some(id.clone())
646-
} else {
647-
None
648-
}
652+
.filter_map(|(id, data)| match data.state {
653+
TrustQuorumMemberState::Unacked => Some(id.clone()),
654+
TrustQuorumMemberState::Prepared => Some(id.clone()),
655+
TrustQuorumMemberState::Committed => None,
649656
})
650657
.collect();
651658
let state = if value.state.is_committed() {

0 commit comments

Comments
 (0)