Skip to content

Commit 06fd7fd

Browse files
authored
feat: add skip_wal_replay to OpenRegion instruction (GreptimeTeam#2977)
feat: add skip_wal_replay to OpenRegion instruction
1 parent d7b2e79 commit 06fd7fd

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

src/common/meta/src/instruction.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ pub struct OpenRegion {
9898
pub region_options: HashMap<String, String>,
9999
#[serde(default)]
100100
pub region_wal_options: HashMap<String, String>,
101+
#[serde(default)]
102+
pub skip_wal_replay: bool,
101103
}
102104

103105
impl OpenRegion {
@@ -106,12 +108,14 @@ impl OpenRegion {
106108
path: &str,
107109
region_options: HashMap<String, String>,
108110
region_wal_options: HashMap<String, String>,
111+
skip_wal_replay: bool,
109112
) -> Self {
110113
Self {
111114
region_ident,
112115
region_storage_path: path.to_string(),
113116
region_options,
114117
region_wal_options,
118+
skip_wal_replay,
115119
}
116120
}
117121
}
@@ -227,12 +231,13 @@ mod tests {
227231
"test/foo",
228232
HashMap::new(),
229233
HashMap::new(),
234+
false,
230235
));
231236

232237
let serialized = serde_json::to_string(&open_region).unwrap();
233238

234239
assert_eq!(
235-
r#"{"OpenRegion":{"region_ident":{"cluster_id":1,"datanode_id":2,"table_id":1024,"region_number":1,"engine":"mito2"},"region_storage_path":"test/foo","region_options":{},"region_wal_options":{}}}"#,
240+
r#"{"OpenRegion":{"region_ident":{"cluster_id":1,"datanode_id":2,"table_id":1024,"region_number":1,"engine":"mito2"},"region_storage_path":"test/foo","region_options":{},"region_wal_options":{},"skip_wal_replay":false}}"#,
236241
serialized
237242
);
238243

@@ -289,6 +294,7 @@ mod tests {
289294
region_storage_path,
290295
region_options,
291296
region_wal_options: HashMap::new(),
297+
skip_wal_replay: false,
292298
};
293299
assert_eq!(expected, deserialized);
294300
}

src/datanode/src/heartbeat/handler.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ impl RegionHeartbeatResponseHandler {
5555
region_storage_path,
5656
region_options,
5757
region_wal_options,
58-
}) => Ok(Box::new(|region_server| {
58+
skip_wal_replay,
59+
}) => Ok(Box::new(move |region_server| {
5960
Box::pin(async move {
6061
let region_id = Self::region_ident_to_region_id(&region_ident);
6162
// TODO(niebayes): extends region options with region_wal_options.
@@ -64,7 +65,7 @@ impl RegionHeartbeatResponseHandler {
6465
engine: region_ident.engine,
6566
region_dir: region_dir(&region_storage_path, region_id),
6667
options: region_options,
67-
skip_wal_replay: false,
68+
skip_wal_replay,
6869
});
6970
let result = region_server.handle_request(region_id, request).await;
7071

@@ -244,6 +245,7 @@ mod tests {
244245
path,
245246
HashMap::new(),
246247
HashMap::new(),
248+
false,
247249
))
248250
}
249251

src/meta-srv/src/procedure/region_failover.rs

+1
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ mod tests {
622622
&path,
623623
HashMap::new(),
624624
HashMap::new(),
625+
false
625626
)))
626627
.unwrap(),
627628
))

src/meta-srv/src/procedure/region_failover/activate_region.rs

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ impl ActivateRegion {
9191
&region_storage_path,
9292
region_options.clone(),
9393
region_wal_options.clone(),
94+
false,
9495
));
9596

9697
self.region_storage_path = Some(region_storage_path);
@@ -236,6 +237,7 @@ mod tests {
236237
&env.path,
237238
HashMap::new(),
238239
HashMap::new(),
240+
false
239241
)))
240242
.unwrap(),
241243
))
@@ -307,6 +309,7 @@ mod tests {
307309
&env.path,
308310
HashMap::new(),
309311
HashMap::new(),
312+
false
310313
)))
311314
.unwrap(),
312315
))

src/meta-srv/src/procedure/region_migration/open_candidate_region.rs

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ impl OpenCandidateRegion {
9090
&region_storage_path,
9191
region_options,
9292
region_wal_options,
93+
true,
9394
));
9495

9596
Ok(open_instruction)
@@ -215,6 +216,7 @@ mod tests {
215216
region_storage_path: "/bar/foo/region/".to_string(),
216217
region_options: Default::default(),
217218
region_wal_options: Default::default(),
219+
skip_wal_replay: true,
218220
})
219221
}
220222

0 commit comments

Comments
 (0)