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

Optimistic concurrency control #951

Closed
1 of 6 tasks
wjones127 opened this issue Jun 6, 2023 · 2 comments
Closed
1 of 6 tasks

Optimistic concurrency control #951

wjones127 opened this issue Jun 6, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@wjones127
Copy link
Contributor

wjones127 commented Jun 6, 2023

We don't support concurrent independent writes to the same table. We can move to an optimistic concurrency control model, as used by other table formats like Iceberg and Delta Lake. This means concurrent writes will finish writing data files first, then attempt to commit their manifest file.

Part 1: Commits

The current commit process doesn't check if there already exists a manifest of the current version. We need this check to be atomic with the write operation. This can be accomplished immediately with most object stores other than S3, since they support put-if-not-exist or something similar.

We will have to create a bespoke solution for S3.

Part 2: Conflict resolution

As a first step, we will fail if there is a concurrent write. Next, we need writers to decide what to do when another writer has written a commit before them. They must choose between:

  1. Just increment the version and write the next manifest file. This is appropriate for appends, or if transactions overwrite disjoint partitions.
  2. Rerun or partially rerun the query, and try committing again. For example, if we deleted data, but the winning write appends new data, we can rerun the delete for just the new data files and then try committing again, rather than having to rerun the full delete.
  3. Fail. This can occur if the transactions are totally incompatible. For example, if we are updating a column that the winning transaction removed from the table.
  • Move fragment ids to be generated as UUIDs
  • Move timestamps to be at UTC instead of system time
  • Implement conflict resolution logic to allow certain concurrent writes (such as append) to succeed
  • Implement optimized retries for special cases of conflicting writes
@wjones127 wjones127 added the enhancement New feature or request label Jun 6, 2023
@tustvold
Copy link

tustvold commented Dec 23, 2023

FYI first-party support for this sort of pattern was added to object_store in apache/arrow-rs#4984 and S3 support (using DynamoDB) is being added in apache/arrow-rs#4918 with a view to making the 0.9.0 release - apache/arrow-rs#5224

@wjones127
Copy link
Contributor Author

This is handled.

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

2 participants