fix: Get the file stem rather than file name for the UUID (#6284)
Oops. Stupid mistake, behavior that should have had a test but didn't. Fixes #6270.pull/24376/head
parent
039a45ddd1
commit
eafc0ea131
|
@ -233,8 +233,12 @@ impl Wal {
|
|||
.context(UnableToReadFileMetadataSnafu)?;
|
||||
if metadata.is_file() {
|
||||
let child_path = child.path();
|
||||
let filename = child_path.file_name().unwrap();
|
||||
let filename = filename.to_str().unwrap();
|
||||
let filename = child_path
|
||||
.file_stem()
|
||||
.expect("WAL files created by IOx should have a file stem");
|
||||
let filename = filename
|
||||
.to_str()
|
||||
.expect("WAL files created by IOx should be named with valid UTF-8");
|
||||
let id = Uuid::parse_str(filename)
|
||||
.context(InvalidUuidSnafu { filename })?
|
||||
.into();
|
||||
|
|
|
@ -77,6 +77,37 @@ async fn crud() {
|
|||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn replay() {
|
||||
let dir = test_helpers::tmp_dir().unwrap();
|
||||
|
||||
// Create a WAL with an entry then drop the WAL
|
||||
{
|
||||
let wal = wal::Wal::new(dir.path()).await.unwrap();
|
||||
let open = wal.write_handle().await;
|
||||
let op = arbitrary_sequenced_wal_op(42);
|
||||
open.write_op(op).await.unwrap();
|
||||
let wal_rotator = wal.rotation_handle().await;
|
||||
wal_rotator.rotate().await.unwrap();
|
||||
}
|
||||
|
||||
// Create a new WAL instance with the same directory to replay from the files
|
||||
let wal = wal::Wal::new(dir.path()).await.unwrap();
|
||||
let wal_reader = wal.read_handle();
|
||||
|
||||
// There's one closed segment
|
||||
let closed = wal_reader.closed_segments().await;
|
||||
let closed_segment_ids: Vec<_> = closed.iter().map(|c| c.id()).collect();
|
||||
|
||||
// Can read the written entries from the closed segment
|
||||
let mut reader = wal_reader
|
||||
.reader_for_segment(closed_segment_ids[0])
|
||||
.await
|
||||
.unwrap();
|
||||
let op = reader.next_ops().await.unwrap().unwrap();
|
||||
assert_eq!(op.sequence_number.get(), 42);
|
||||
}
|
||||
|
||||
fn arbitrary_sequenced_wal_op(sequence_number: u64) -> SequencedWalOp {
|
||||
let w = test_data("m1,t=foo v=1i 1");
|
||||
SequencedWalOp {
|
||||
|
|
Loading…
Reference in New Issue