File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/meta/service/src/store Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,9 @@ impl RaftStoreInner {
228228
229229 // Pipe entries to the writer.
230230 {
231+ // Count the user keys and expiration keys.
232+ let mut key_counts = BTreeMap :: < String , u64 > :: new ( ) ;
233+
231234 while let Some ( ent) = strm
232235 . try_next ( )
233236 . await
@@ -236,11 +239,10 @@ impl RaftStoreInner {
236239 // The first 4 chars are key space, such as: "kv--/" or "exp-/"
237240 // Get the first 4 chars as key space.
238241 let prefix = & ent. 0 . as_str ( ) [ ..4 ] ;
239- let ks = sys_data. key_counts_mut ( ) ;
240- if let Some ( count) = ks. get_mut ( prefix) {
242+ if let Some ( count) = key_counts. get_mut ( prefix) {
241243 * count += 1 ;
242244 } else {
243- ks . insert ( prefix. to_string ( ) , 1 ) ;
245+ key_counts . insert ( prefix. to_string ( ) , 1 ) ;
244246 }
245247
246248 tx. send ( WriteEntry :: Data ( ent) )
@@ -250,6 +252,11 @@ impl RaftStoreInner {
250252 raft_metrics:: storage:: incr_snapshot_written_entries ( ) ;
251253 }
252254
255+ {
256+ let ks = sys_data. key_counts_mut ( ) ;
257+ * ks = key_counts;
258+ }
259+
253260 tx. send ( WriteEntry :: Finish ( ( snapshot_id. clone ( ) , sys_data) ) )
254261 . await
255262 . map_err ( |e| StorageError :: write_snapshot ( Some ( signature. clone ( ) ) , & e) ) ?;
You can’t perform that action at this time.
0 commit comments