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

Fix ReadTransaction::close() #813

Merged
merged 1 commit into from
Jun 2, 2024
Merged

Fix ReadTransaction::close() #813

merged 1 commit into from
Jun 2, 2024

Conversation

cberner
Copy link
Owner

@cberner cberner commented Jun 2, 2024

Previously it always returned ReadTransactionStillInUse

Fixes #812

Previously it always returned ReadTransactionStillInUse
@cberner cberner merged commit f26cdb2 into master Jun 2, 2024
3 checks passed
@cberner cberner deleted the close_txn branch June 2, 2024 03:38
@@ -1298,7 +1296,9 @@ impl ReadTransaction {
///
/// Returns `ReadTransactionStillInUse` error if a table or other object retrieved from the transaction still references this transaction
pub fn close(self) -> Result<(), TransactionError> {
if Arc::strong_count(&self.transaction_guard) > 1 {
let cloned = self.tree.clone_transaction_guard();
Copy link
Contributor

Choose a reason for hiding this comment

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

As an alternative, one could have added an accessor like

fn transaction_guard(&self) -> &Arc<TransactionGuard>;

to avoid the unnecessary clone here. The cloning itself could then still just be written as

Arc::clone(self.tree.transaction_gurard())

without adding another method.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Oh ya, that's cleaner. #814

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.

Error ReadTransactionStillInUse(ReadTransaction) when try to close transaction
2 participants