Skip to content

Hive locking#405

Merged
danielcweeks merged 12 commits intoapache:mainfrom
danielcweeks:hive-locking
Feb 10, 2024
Merged

Hive locking#405
danielcweeks merged 12 commits intoapache:mainfrom
danielcweeks:hive-locking

Conversation

@danielcweeks
Copy link
Copy Markdown
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
Copy Markdown
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 thread pyiceberg/catalog/hive.py Outdated
Comment thread pyiceberg/catalog/hive.py Outdated
Comment thread tests/integration/test_reads.py Outdated
Comment thread tests/integration/test_reads.py Outdated
Comment thread pyiceberg/catalog/hive.py
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
Copy Markdown
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
Copy Markdown
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