sentinel-group / sentinel-rust

Sentinel Rust version
Apache License 2.0
132 stars 22 forks source link

find_offset_to_start read wrong length of bytes #146

Closed flearc closed 7 months ago

flearc commented 7 months ago

find_offset_to_start read 4 bytes from the idx file as the offset.

But write_index use 8 bytes to store it.

fn write_index(&self, time: u64, offset: u64) -> Result<()> {
    // Use BigEndian here to keep consistent with DataOutputStream in Java.
    let mut idx_out = self.cur_metric_idx_file.as_ref().unwrap().write().unwrap();
    idx_out.write_all(&time.to_be_bytes())?;
    idx_out.write_all(&offset.to_be_bytes())?;
    idx_out.flush()?;
    Ok(())
}