Skip to content

Commit

Permalink
[Data] Disable multithreaded reads if preserve_order is enabled (#4…
Browse files Browse the repository at this point in the history
…6135)

Multithreaded reads can cause non-deterministic ordering of output rows.

Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
  • Loading branch information
bveeramani authored Jun 19, 2024
1 parent ceb02aa commit 5279db6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/ray/data/datasource/file_based_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ def create_read_task_fn(read_paths, num_threads):
def read_task_fn():
nonlocal num_threads, read_paths

# TODO: We should refactor the code so that we can get the results in
# order even when using multiple threads.
if ctx.execution_options.preserve_order:
num_threads = 0

if num_threads > 0:
if len(read_paths) < num_threads:
num_threads = len(read_paths)
Expand Down

0 comments on commit 5279db6

Please sign in to comment.