Skip to content

Commit e21396c

Browse files
Fix deserialization from old data format
All nanosecond-encoded time fields should deserialize from either a number or the "big" Duration encoding.
1 parent 189082d commit e21396c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

collector/src/bin/recode.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use collector::{CommitData};
1+
use collector::CommitData;
22
use std::fs;
33

44
fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -14,16 +14,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1414
if filename.starts_with("commit-") && filename.ends_with(".sz") {
1515
eprintln!("{:?}", filename);
1616
use std::io::Read;
17-
let mut out =
18-
String::with_capacity(snap::decompress_len(&file_contents).unwrap_or(0));
17+
let mut out = String::with_capacity(snap::decompress_len(&file_contents).unwrap_or(0));
1918
let mut szip_reader = snap::Reader::new(&file_contents[..]);
2019
szip_reader.read_to_string(&mut out).unwrap();
2120
let file_contents = out.as_str();
2221

2322
let contents: CommitData = match serde_json::from_str(&file_contents) {
2423
Ok(json) => json,
2524
Err(err) => {
26-
log::error!("Failed to parse JSON for {}: {:?}", filename, err);
25+
eprintln!("Failed to parse JSON for {}: {:?}", filename, err);
2726
continue;
2827
}
2928
};

collector/src/self_profile.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ pub struct QueryData {
102102
self_time: u64,
103103
pub number_of_cache_hits: u32,
104104
pub invocation_count: u32,
105+
#[serde(deserialize_with = "SerdeDuration::into_nanos")]
105106
blocked_time: u64,
107+
#[serde(deserialize_with = "SerdeDuration::into_nanos")]
106108
incremental_load_time: u64,
107109
}
108110

109-
#[derive(Deserialize)]
111+
#[derive(Debug, Deserialize)]
110112
#[serde(untagged)]
111113
enum SerdeDuration {
112114
Nanoseconds(u64),

0 commit comments

Comments
 (0)