@@ -62,7 +62,7 @@ impl SnapshotPartitionTask {
62
62
)
63
63
. await ?;
64
64
65
- let metadata = self . write_snapshot_metadata_header ( & snapshot) . await ? ;
65
+ let metadata = self . metadata ( & snapshot, SystemTime :: now ( ) ) ;
66
66
67
67
self . snapshot_repository
68
68
. put ( & metadata, snapshot. base_dir )
@@ -72,36 +72,22 @@ impl SnapshotPartitionTask {
72
72
Ok ( metadata)
73
73
}
74
74
75
- async fn write_snapshot_metadata_header (
75
+ fn metadata (
76
76
& self ,
77
77
snapshot : & LocalPartitionSnapshot ,
78
- ) -> Result < PartitionSnapshotMetadata , SnapshotError > {
79
- let snapshot_meta = PartitionSnapshotMetadata {
78
+ created_at : SystemTime ,
79
+ ) -> PartitionSnapshotMetadata {
80
+ PartitionSnapshotMetadata {
80
81
version : SnapshotFormatVersion :: V1 ,
81
82
cluster_name : self . cluster_name . clone ( ) ,
82
83
node_name : self . node_name . clone ( ) ,
83
84
partition_id : self . partition_id ,
84
- created_at : humantime:: Timestamp :: from ( SystemTime :: now ( ) ) ,
85
+ created_at : humantime:: Timestamp :: from ( created_at ) ,
85
86
snapshot_id : self . snapshot_id ,
86
87
key_range : snapshot. key_range . clone ( ) ,
87
88
min_applied_lsn : snapshot. min_applied_lsn ,
88
89
db_comparator_name : snapshot. db_comparator_name . clone ( ) ,
89
90
files : snapshot. files . clone ( ) ,
90
- } ;
91
- let metadata_json =
92
- serde_json:: to_string_pretty ( & snapshot_meta) . expect ( "Can always serialize JSON" ) ;
93
-
94
- let metadata_path = snapshot. base_dir . join ( "metadata.json" ) ;
95
- tokio:: fs:: write ( metadata_path. clone ( ) , metadata_json)
96
- . await
97
- . map_err ( |e| SnapshotError :: SnapshotIoError ( self . partition_id , e) ) ?;
98
-
99
- debug ! (
100
- lsn = %snapshot. min_applied_lsn,
101
- "Partition snapshot metadata written to {:?}" ,
102
- metadata_path
103
- ) ;
104
-
105
- Ok ( snapshot_meta)
91
+ }
106
92
}
107
93
}
0 commit comments