Skip to content

fix(arrow): wake equality-delete waiters with the notifier of the started load - #3697

Merged
laskoviymishka merged 2 commits into
apache:mainfrom
c-thiel:ct/fix-eq-delete-waiter-notifier
Nov 16, 2026
Merged

laskoviymishka merged 2 commits into
apache:mainfrom
c-thiel:ct/fix-eq-delete-waiter-notifier

Conversation

@c-thiel

@c-thiel c-thiel commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Which issue does this PR close?

No issue yet. A scan can hang forever when two data files share an equality delete file: a task can wait on a notifier that is never woken.

@JeonDaehong found this race and proposed this fix on #3275, planned as a follow-up once the open PR limit allows. This PR sends that fix now, with @JeonDaehong as co-author of the commit. The reviews of #2873 and #3268 also raised it.

What changes are included in this PR?

CachingDeleteFileLoader marks an equality delete file as loading with try_start_eq_del_load, which stores a notifier. It then calls insert_equality_delete, which replaced that state with a second notifier and woke only the second one when the predicate arrived. A task that read the state between the two calls waited on the first notifier forever, so the record batch stream from ArrowReader::read never finished. This needs a multi-thread runtime and a pause between the two calls, so it is rare, but the hang is permanent.

insert_equality_delete now takes the notifier from try_start_eq_del_load and keeps the loading state that it set. A failed load is a separate case (#3274, #3275).

Are these changes tested?

Yes, in arrow::delete_filter:

  • test_eq_del_waiter_registered_before_insert_is_woken registers a waiter between the two calls and checks that it gets the predicate. Without the fix it times out.
  • test_build_equality_delete_predicate_case_sensitive now starts the load first, as the loader does.

AI Disclosure

Supported by Claude Code. Reviewed and checked by me.

@JeonDaehong JeonDaehong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @c-thiel for picking this up, and for the co-author credit! I checked that the new test catches the bug. With the old behavior put back in insert_equality_delete (a fresh Notify stored over the one from try_start_eq_del_load), the test times out after 5s. With the fix it passes, and so do the arrow:: tests on 3db15d4. The other case from #3275 (notified_owned() under the lock) is already on main, so this closes out both. LGTM.

*entry.lock().unwrap() |= delete_vector;
}

/// Stores the equality delete predicate that `eq_del` delivers, and wakes the tasks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this no longer writes the Loading state itself, it now relies on try_start_eq_del_load having stored notify for this path. A caller that skips that step would leave no entry, and get_equality_delete_predicate_for_delete_file_path returns None for a missing entry, so the delete would be silently skipped rather than hang. Maybe say this in the doc comment, or add a debug_assert! that the entry is Loading(notify)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think a missing entry wouldn't skip the delete silently, though: build_equality_delete_predicate turns the None into an Unexpected error ("Missing predicate for equality delete file …"). I think the case worth guarding is a different notifier, which would leave the waiters hanging again, as in the bug here. So I added a debug_assert! that the entry is Loading with this exact notifier, like the one in abandon_pos_del_load. Every test that loads equality deletes through the loader now checks it. 5139400

Makes sense?


let mut waiter = Box::pin(filter.get_equality_delete_predicate_for_delete_file_path(path));
// Registers the waiter on the notifier that `try_start_eq_del_load` stored.
assert!(futures::poll!(&mut waiter).is_pending());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Polling once here makes the window deterministic without a multi-thread runtime or a sleep. My repro on #3275 needed both, so this is a much better test.

@laskoviymishka laskoviymishka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @c-thiel for sending the #3275 fix now rather than waiting on the PR limit. As I read it, waiters register notified_owned() on the same Notify that try_start_eq_del_load stored, and tokio guarantees a created Notified gets notify_waiters() even before its first poll (notify.rs), so nobody is left on a stale notifier.

@laskoviymishka
laskoviymishka added this pull request to the merge queue Nov 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 16, 2026
@laskoviymishka
laskoviymishka added this pull request to the merge queue Nov 16, 2026
Merged via the queue into apache:main with commit ff05641 Nov 16, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants