Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion crates/paimon/src/io/cache/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,13 @@ impl DiskCache {
return;
}
};
if let Err(error) = temporary_file.write_all(&encoded).await {
let write_result = async {
temporary_file.write_all(&encoded).await?;
// Tokio may return from write_all before the blocking write completes.
temporary_file.flush().await
}
.await;
if let Err(error) = write_result {
log::debug!(
"Failed to write local cache temporary block '{}': {error}",
temporary.display()
Expand Down Expand Up @@ -846,6 +852,11 @@ mod tests {

let cache = DiskCache::new(directory.path(), None).unwrap();
cache.put_block(&key, payload.clone()).await;
// Check publication without scheduling another Tokio filesystem operation.
assert_eq!(
std::fs::read(directory.path().join(key.cache_relative_path())).unwrap(),
encode_block(&key, &payload)
);
assert_eq!(cache.get_block(&key).await, Some(payload.clone()));
drop(cache);

Expand Down
Loading