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 acl map num #33246

Merged
merged 5 commits into from
Jan 8, 2022
Merged

Fix acl map num #33246

merged 5 commits into from
Jan 8, 2022

Conversation

nicelulu
Copy link
Contributor

Changelog category (leave one):

  • Bug Fix (user-visible misbehaviour in official stable or prestable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix ACLMap num, because acl_to_num will erase.

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Dec 28, 2021
@alesapin alesapin self-assigned this Dec 28, 2021
@alesapin alesapin added the can be tested Allows running workflows for external contributors label Dec 28, 2021
if (acl_to_num.count(acls))
return acl_to_num[acls];

/// Start from one
auto index = acl_to_num.size() + 1;
auto index = max_acl_id++;
Copy link
Member

@alesapin alesapin Dec 28, 2021

Choose a reason for hiding this comment

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

Can you describe the issue in details? As far as I can see we will restore acl_to_num and num_to_acl from logs/snapshot and everything should work well. Why it will erase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will erase from removeUsage method.

Copy link
Member

Choose a reason for hiding this comment

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

But why it's a problem? If nobody uses some id from map than we can reuse it again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because after erasing, the size will be reduced. When a new acls comes in, it will be assigned an index equal to the current maximum index so that the original acls will be overwritten.

Copy link
Member

@alesapin alesapin Jan 7, 2022

Choose a reason for hiding this comment

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

But an ID can be erased from map only when nobody use this ID and it should be safe to reuse it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add some tests to be more intuitive.

@alesapin alesapin merged commit 0860acb into ClickHouse:master Jan 8, 2022
@alesapin
Copy link
Member

alesapin commented Jan 8, 2022

Clear to me. We will get an issue when one ACL is removed and new added.

@alesapin
Copy link
Member

alesapin commented Jan 8, 2022

@nicelulu Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can be tested Allows running workflows for external contributors pr-bugfix Pull request with bugfix, not backported by default
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants