Skip to content

Commit 329ef26

Browse files
committed
fix: avoid lost-wakeup hang in get_equality_delete_predicate_for_delete_file_path
The equality-delete loader signals completion with Notify::notify_waiters(), which stores no permit and only wakes Notified futures created before the call. get_equality_delete_predicate_for_delete_file_path observed the Loading state, released the read lock, and only then created the Notified future; a notify_waiters() fired in that window is lost and the await hangs forever. Create the Notified (via notified_owned) while still holding the read lock, so it is guaranteed to precede any notify_waiters() and be delivered. Signed-off-by: Dhruv Arya <[email protected]>
1 parent e8460ee commit 329ef26

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,22 @@ impl DeleteFilter {
163163
&self,
164164
file_path: &str,
165165
) -> Option<Predicate> {
166-
let notifier = {
166+
// Create the `Notified` while holding the read lock. The read lock ensures that
167+
// when we go inside it, either the state is already at Loaded or it is still at
168+
// Loading AND `notify_waiters()` has not been called yet. Any `Notified` created
169+
// before the invocation of `notify_waiters()` will be notified by it even if
170+
// `await` has not been called on it yet.
171+
let notified = {
167172
match self.state.read().unwrap().equality_deletes.get(file_path) {
168173
None => return None,
169-
Some(EqDelState::Loading(notifier)) => notifier.clone(),
174+
Some(EqDelState::Loading(notifier)) => notifier.clone().notified_owned(),
170175
Some(EqDelState::Loaded(predicate)) => {
171176
return Some(predicate.clone());
172177
}
173178
}
174179
};
175180

176-
notifier.notified().await;
181+
notified.await;
177182

178183
match self.state.read().unwrap().equality_deletes.get(file_path) {
179184
Some(EqDelState::Loaded(predicate)) => Some(predicate.clone()),

0 commit comments

Comments
 (0)