Skip to content

Commit 2be2c8a

Browse files
committed
chore(meta): remove unused code
1 parent 56d6b1f commit 2be2c8a

File tree

3 files changed

+4
-34
lines changed

3 files changed

+4
-34
lines changed

src/meta/raft-store/src/state_machine/sm.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ impl StateMachine {
10461046
sm_nodes.range_values(..)
10471047
}
10481048

1049-
/// Expire an `SeqV` and returns:
1049+
/// Expire an `SeqV` and returns the value discarded by expiration and the unexpired value:
10501050
/// - `(Some, None)` if it expires.
10511051
/// - `(None, Some)` if it does not.
10521052
/// - `(None, None)` if the input is None.
@@ -1064,32 +1064,6 @@ impl StateMachine {
10641064
(None, None)
10651065
}
10661066
}
1067-
1068-
pub fn unexpired<V: Debug>(seq_value: SeqV<V>, log_time_ms: u64) -> Option<SeqV<V>> {
1069-
// Caveat: The cleanup must be consistent across raft nodes:
1070-
// A conditional update, e.g. an upsert_kv() with MatchSeq::Eq(some_value),
1071-
// must be applied with the same timestamp on every raft node.
1072-
// Otherwise: node-1 could have applied a log with a ts that is smaller than value.expire_at,
1073-
// while node-2 may fail to apply the same log if it use a greater ts > value.expire_at.
1074-
//
1075-
// Thus:
1076-
//
1077-
// 1. A raft log must have a field ts assigned by the leader. When applying, use this ts to
1078-
// check against expire_at to decide whether to purge it.
1079-
// 2. A GET operation must not purge any expired entry. Since a GET is only applied to a node itself.
1080-
// 3. The background task can only be triggered by the raft leader, by submit a "clean expired" log.
1081-
1082-
// TODO(xp): background task to clean expired
1083-
// TODO(xp): maybe it needs a expiration queue for efficient cleaning up.
1084-
1085-
debug!("seq_value: {:?} log_time_ms: {}", seq_value, log_time_ms);
1086-
1087-
if seq_value.get_expire_at() < log_time_ms {
1088-
None
1089-
} else {
1090-
Some(seq_value)
1091-
}
1092-
}
10931067
}
10941068

10951069
/// Key space support

src/meta/raft-store/src/state_machine/sm_kv_api_impl.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,10 @@ impl KVApi for StateMachine {
7575
// TODO(xp) refine get(): a &str is enough for key
7676
let sv = self.kvs().get(&key.to_string())?;
7777
debug!("get_kv sv:{:?}", sv);
78-
let seq_v = match sv {
79-
None => return Ok(None),
80-
Some(sv) => sv,
81-
};
8278

8379
let local_now_ms = SeqV::<()>::now_ms();
84-
Ok(Self::unexpired(seq_v, local_now_ms))
80+
let (_expired, res) = Self::expire_seq_v(sv, local_now_ms);
81+
Ok(res)
8582
}
8683

8784
async fn mget_kv(&self, keys: &[String]) -> Result<MGetKVReply, KVAppError> {
@@ -111,7 +108,7 @@ impl KVApi for StateMachine {
111108
let local_now_ms = SeqV::<()>::now_ms();
112109

113110
// Convert expired to None
114-
let x = x.map(|(k, v)| (k, Self::unexpired(v, local_now_ms)));
111+
let x = x.map(|(k, v)| (k, Self::expire_seq_v(Some(v), local_now_ms)[1]));
115112
// Remove None
116113
let x = x.filter(|(_k, v)| v.is_some());
117114
// Extract from an Option

src/meta/service/tests/it/tests/meta_node.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pub(crate) async fn start_meta_node_cluster(
3535
voters: BTreeSet<NodeId>,
3636
non_voters: BTreeSet<NodeId>,
3737
) -> anyhow::Result<(u64, Vec<MetaSrvTestContext>)> {
38-
// TODO(xp): use setup_cluster if possible in tests. Get rid of boilerplate snippets.
3938
// leader is always node-0
4039
assert!(voters.contains(&0));
4140
assert!(!non_voters.contains(&0));

0 commit comments

Comments
 (0)