| 371 | |
| 372 | #[test] |
| 373 | fn uring_reopen_continues_lsn() { |
| 374 | let dir = tempfile::tempdir().unwrap(); |
| 375 | let path = dir.path().join("uring_reopen.wal"); |
| 376 | |
| 377 | { |
| 378 | let mut writer = UringWriter::open_without_direct_io(&path).unwrap(); |
| 379 | writer |
| 380 | .append(RecordType::Put as u32, 1, 0, 0, b"first") |
| 381 | .unwrap(); |
| 382 | writer |
| 383 | .append(RecordType::Put as u32, 1, 0, 0, b"second") |
| 384 | .unwrap(); |
| 385 | writer.submit_and_sync().unwrap(); |
| 386 | } |
| 387 | |
| 388 | { |
| 389 | let mut writer = UringWriter::open_without_direct_io(&path).unwrap(); |
| 390 | assert_eq!(writer.next_lsn(), 3); |
| 391 | let lsn = writer |
| 392 | .append(RecordType::Put as u32, 1, 0, 0, b"third") |
| 393 | .unwrap(); |
| 394 | assert_eq!(lsn, 3); |
| 395 | writer.submit_and_sync().unwrap(); |
| 396 | } |
| 397 | |
| 398 | let reader = WalReader::open(&path).unwrap(); |
| 399 | let records: Vec<_> = reader |
| 400 | .records() |
| 401 | .collect::<crate::error::Result<_>>() |
| 402 | .unwrap(); |
| 403 | assert_eq!(records.len(), 3); |
| 404 | } |
| 405 | } |