Skip to content

Commit 0aa573e

Browse files
committed
Add a connection_id field to the Client
1 parent 574ffe9 commit 0aa573e

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

upstairs/src/client.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ pub(crate) struct DownstairsClient {
195195

196196
/// State for startup negotiation
197197
negotiation_state: NegotiationState,
198+
199+
/// Session ID for a clients connection to a downstairs.
200+
connection_id: usize,
198201
}
199202

200203
impl DownstairsClient {
@@ -231,6 +234,7 @@ impl DownstairsClient {
231234
region_metadata: None,
232235
repair_info: None,
233236
io_state_count: ClientIOStateCount::new(),
237+
connection_id: 0,
234238
}
235239
}
236240

@@ -267,6 +271,7 @@ impl DownstairsClient {
267271
region_metadata: None,
268272
repair_info: None,
269273
io_state_count: ClientIOStateCount::new(),
274+
connection_id: 0,
270275
}
271276
}
272277

@@ -604,6 +609,7 @@ impl DownstairsClient {
604609
self.state = DsState::New;
605610
}
606611

612+
self.connection_id += 1;
607613
// Restart with a short delay
608614
self.start_task(true, auto_promote);
609615
}
@@ -2185,13 +2191,13 @@ impl DownstairsClient {
21852191
(self.io_state_count.new + self.io_state_count.in_progress) as usize
21862192
}
21872193

2188-
/// Returns a unique ID for the current connect, or `None`
2194+
/// Returns a unique ID for the current connection, or `None`
21892195
///
21902196
/// This can be used to disambiguate between messages returned from
21912197
/// different connections to the same Downstairs.
21922198
pub(crate) fn get_connection_id(&self) -> Option<u64> {
21932199
if self.client_task.client_stop_tx.is_some() {
2194-
Some(self.stats.connected as u64)
2200+
Some(self.connection_id as u64)
21952201
} else {
21962202
None
21972203
}

upstairs/src/downstairs.rs

-20
Original file line numberDiff line numberDiff line change
@@ -3046,26 +3046,6 @@ impl Downstairs {
30463046
);
30473047
return Err(CrucibleError::NoLongerActive);
30483048
}
3049-
DsState::Offline => {
3050-
// If we have gone offline, it's possible that a job landed just
3051-
// before the downstairs went away. If we have moved jobs to New, it
3052-
// means we plan to replay them and we can discard this job now.
3053-
if let Some(job) = self.ds_active.get(&ds_id) {
3054-
if job.state[client_id] == IOState::New {
3055-
warn!(
3056-
self.clients[client_id].log,
3057-
"Drop job {} because we are {}", ds_id, ds_state
3058-
);
3059-
return Err(CrucibleError::NoLongerActive);
3060-
}
3061-
}
3062-
warn!(
3063-
self.clients[client_id].log,
3064-
"{} WARNING finish job {} when downstairs Offline",
3065-
self.cfg.upstairs_id,
3066-
ds_id,
3067-
);
3068-
}
30693049
_ => {
30703050
warn!(
30713051
self.clients[client_id].log,

0 commit comments

Comments
 (0)