Skip to content

Commit 765f199

Browse files
committed
test(reader): resolve unknown delete sizes once under concurrent loads
1 parent a3cb29c commit 765f199

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎crates/iceberg/src/arrow/caching_delete_file_loader.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,7 @@ mod tests {
12641264
let factory = Arc::new(MetadataCountingStorageFactory::default());
12651265
let calls = Arc::clone(&factory.calls);
12661266
let file_io = FileIOBuilder::new(factory).build();
1267+
let file_io_for_join = file_io.clone();
12671268
let task = &file_scan_tasks[0];
12681269
let unknown: Vec<_> = task
12691270
.deletes()
@@ -1308,6 +1309,19 @@ mod tests {
13081309
let expected = positions(&known);
13091310
assert_eq!(expected.len(), 12);
13101311
assert_eq!(positions(&lazy), expected);
1312+
1313+
// Two concurrent loads of the same files on a fresh loader: the second waits on
1314+
// the first instead of requesting the sizes again.
1315+
let before = calls.load(Ordering::SeqCst);
1316+
let loader = CachingDeleteFileLoader::new(file_io_for_join, 10, Runtime::current());
1317+
let (first, second) = futures::join!(
1318+
loader.load_deletes(&unknown, task.schema_ref()),
1319+
loader.load_deletes(&unknown, task.schema_ref())
1320+
);
1321+
let (first, second) = (first.unwrap().unwrap(), second.unwrap().unwrap());
1322+
assert_eq!(calls.load(Ordering::SeqCst) - before, unknown.len());
1323+
assert_eq!(positions(&first), expected);
1324+
assert_eq!(positions(&second), expected);
13111325
}
13121326

13131327
#[tokio::test]

0 commit comments

Comments
 (0)