Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race conditions when writing / reading parquet datasets #3021

Open
pvieito opened this issue Nov 15, 2024 · 0 comments
Open

Race conditions when writing / reading parquet datasets #3021

pvieito opened this issue Nov 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@pvieito
Copy link

pvieito commented Nov 15, 2024

Hi! Currently when writting a parquet dataset with mode overwrite / overwrite_partitions it creates a race condition between the writter and any reader (aws-wranlger / Spark / Athena for example) as aws-wrangler first removes the files in each partition and then it creates objects with new random UUID-based names.

This behaviour is quite unsafe as any reader listing the object in the overwrite moment and then trying to read them will fail with some of these errors (or worse, it will fail silently because it just listed the path after aws-wrangler removed all the files, and sees and empty dataset):

  • botocore.errorfactory.NoSuchKey: An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist.
  • Athena: HIVE_CANNOT_OPEN_SPLIT errors
  • etc.

We would like a new option to ensure that in overwrite & overwrite_partitions modes aws-wrangler does a safe, deterministic & atomical replacement of the destinations object, this could be done using this method:

  • Having deterministic output names (for example part-0.parquet, part-1.parquet).
  • Atomically replacing any existing files in the output path.
  • Finally doing the clean-up of any extra files that are not expected in the output path (if in this new upload there are less part files, for example).

This would avoid the vast majority of race-conditions as in most cases the number of parts would stay the same or increment in case of a typical overwrite.

// cc. @jack-dell

@pvieito pvieito added the enhancement New feature or request label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant