Skip to content

Conversation

@danielcweeks
Copy link
Contributor

This PR adds locking to the hive commit path for tables. The current commit path is unsafe as competing updates may overwrite other clients that are using locking.

This implementation is the most restrictive in that it will fail a commit if it cannot immediately acquire a lock.

@danielcweeks danielcweeks requested a review from Fokko February 10, 2024 03:34
Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

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

This is a big one, thanks for fixing this @danielcweeks

@syun64 We want to add this to the 0.6.0 as well

Comment on lines +397 to +400
except NoSuchObjectException as e:
raise NoSuchTableError(f"Table does not exist: {table_name}") from e
finally:
open_client.unlock(UnlockRequest(lockid=lock.lockid))
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't consider this a blocker, but it'd be nice to have a test to verify that in case of any exception thrown we do actually perform the unlock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a really hard one because it requires that we've already acquired the lock, but then something happened (timeout?) and the the lock state changed. I'd have to think though how we could replicate that scenario.

@danielcweeks danielcweeks merged commit 2e67308 into apache:main Feb 10, 2024
@Fokko Fokko added this to the PyIceberg 0.6.0 release milestone Feb 10, 2024
@danielcweeks danielcweeks deleted the hive-locking branch February 10, 2024 23:38
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