(&mut self)
| 415 | } |
| 416 | |
| 417 | async fn flush_and_sync(&mut self) -> io::Result<()> { |
| 418 | self.segment.flush().await?; |
| 419 | self.segment.fsync().await; |
| 420 | if let Some(mut index) = self.offset_index.take() { |
| 421 | let index = spawn_blocking(move || { |
| 422 | index |
| 423 | .fsync() |
| 424 | .inspect_err(|e| warn!("offset index fsync failed: {e}")) |
| 425 | .ok(); |
| 426 | index |
| 427 | }) |
| 428 | .await |
| 429 | .unwrap(); |
| 430 | self.offset_index = Some(index); |
| 431 | } |
| 432 | |
| 433 | Ok(()) |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | /// Create a new segment at offset `last_written_tx_range.end`. |