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

refactor: grant_ownership retry logic #15275

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

TCeason
Copy link
Collaborator

@TCeason TCeason commented Apr 19, 2024

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

Summary

Before this pr, if the transaction execution of granting ownership fails, it will be retried immediately.

This often leads to frequent failures when multiple connections are simultaneously executing grant ownership.

This is because the role key may cause conflicts. A better solution is to store object and privilege separately as key-value pairs.

However, this solution involves significant changes. This PR temporarily adjusts the retry mechanism(
Tthe role information will be reacquired with each retry, aiming to minimize conflicts.).

No TxnRetryMaxTimes errors occurred during local testing.

Local Test

Environment

create user a identified by '123' with DEFAULT_ROLE='role1';
create role role1;
grant role role1 to a;
grant create database on *.* to role role1;
-- user a
create database a;

script1:

$ cat create.sh
#!/bin/bash  
  
for((i=1;i<=5000;i++));  
do   
	echo "create table if not exists a.t_$i(id int)" | bendsql -ua -p123

done 

script2:

$ cat create1.sh
#!/bin/bash  
  
for((i=5001;i<=10000;i++));  
do   
	echo "create table if not exists a.t_$i(id int)" | bendsql -ua -p123

done 

Test

-- session1
bash ./create.sh

-- session2
bash ./create1.sh

Error Error: APIError: ResponseError with 2317: TxnRetryMaxTimes: Txn grant_ownership has retry 60 times, abort. not occurs.

  • Fixes #[Link the issue here]

Tests

  • No Test refactor while logic. if all ci pass, pr is ok.

Type of change

  • Refactoring

This change is Reviewable

@github-actions github-actions bot added the pr-refactor this PR changes the code base without new features or bugfix label Apr 19, 2024
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 r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @BohuTANG)

@BohuTANG BohuTANG merged commit 4b7d767 into datafuselabs:main Apr 19, 2024
73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-refactor this PR changes the code base without new features or bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants