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

chore: drop guard when acquire lock failed #16616

Merged
merged 5 commits into from
Oct 17, 2024

Conversation

zhyass
Copy link
Member

@zhyass zhyass commented Oct 15, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

Drop guard when acquire lock failed, to avoid drop lock twice.

2024-10-15 22:55:48.406	
[0] DEBUG - c1f03c4f-d9dd-4fda-a634-d841fb350a96 -  databend_common_meta_api::schema_api_impl::<impl databend_common_meta_api::schema_api::SchemaApi for _>::delete_lock_revision(self, req = DeleteLockRevReq { lock_key: Table { tenant: Tenant { tenant: "tnc7yee14" }, table_id: 9036244 }, revision: 9036472 }) => Ok(())
... ...
2024-10-15 22:55:48.406	
[0] DEBUG - c1f03c4f-d9dd-4fda-a634-d841fb350a96 -  SchemaApi: delete_lock_revision
2024-10-15 22:55:48.406	
[0] DEBUG - c1f03c4f-d9dd-4fda-a634-d841fb350a96 -  databend_common_meta_api::schema_api_impl::<impl databend_common_meta_api::schema_api::SchemaApi for _>::delete_lock_revision(self, req = DeleteLockRevReq { lock_key: Table { tenant: Tenant { tenant: "tnc7yee14" }, table_id: 9036244 }, revision: 9036472 }) => Ok(())

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@zhyass zhyass marked this pull request as draft October 15, 2024 16:27
@github-actions github-actions bot added the pr-chore this PR only has small changes that no need to record, like coding styles. label Oct 15, 2024
@zhyass zhyass added the ci-cloud Build docker image for cloud test label Oct 16, 2024
Copy link
Contributor

Docker Image for PR

  • tag: pr-16616-176df86-1729043184

note: this image tag is only available for internal use,
please check the internal doc for more details.

@zhyass zhyass marked this pull request as ready for review October 16, 2024 06:27
Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 3 files at r1, all commit messages.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @dantengsky and @zhyass)


src/query/service/src/locks/lock_manager.rs line 214 at r1 (raw file):

            )))
        } else {
            Ok(Some(Arc::new(guard)))

If the guard is only returned when the lock is successfully acquired, there's no need to create it at the beginning of the function. Instead, create the guard immediately after acquiring the lock and just before returning it. This approach is more efficient and clearly ties the guard's lifetime to the lock's acquisition.

Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dantengsky and @zhyass)

Copy link
Member

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dantengsky and @zhyass)

@zhyass zhyass added this pull request to the merge queue Oct 17, 2024
@BohuTANG BohuTANG removed this pull request from the merge queue due to a manual request Oct 17, 2024
@BohuTANG BohuTANG merged commit 6f70937 into databendlabs:main Oct 17, 2024
73 of 74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-cloud Build docker image for cloud test pr-chore this PR only has small changes that no need to record, like coding styles.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants