Skip to content

Add a property to limit user instance num.#6159

Merged
morningman merged 2 commits intoapache:masterfrom
liutang123:max_query_instances
Jul 10, 2021
Merged

Add a property to limit user instance num.#6159
morningman merged 2 commits intoapache:masterfrom
liutang123:max_query_instances

Conversation

@liutang123
Copy link
Contributor

Proposed changes

Add a property to limit user instance num.

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Code refactor (Modify the code structure, format the code, etc...)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have created an issue on (Fix [Feature] Add user property to limit the instance num #6158) and described the bug/feature there in detail
  • Compiling and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • If these changes need document changes, I have updated the document
  • Any dependent changes have been merged

Further comments

!Strings.isNullOrEmpty(queryInfo.getConnectContext().getQualifiedUser())
) {
String user = queryInfo.getConnectContext().getQualifiedUser();
long maxQueryInstances = queryInfo.getConnectContext().getCatalog().getAuth().getMaxQueryInstances(user);
Copy link
Contributor

Choose a reason for hiding this comment

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

maxQueryInstances can be saved in ConnectionContext when connection established, so that no need to calculate this variables at every registerInstances()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If save maxQueryInstances in ConnectionContext , we can not change it after ConnectionContext created.
getMaxQueryInstances will try to obtain an read lock in PlaoAuth. I think the cost should be very small, because it is a situation of reading more and writing less.

However, we can update parameters and disconnect all links to make parameters take effect.

Copy link
Contributor

Choose a reason for hiding this comment

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

I made a test, in high concurrency scenarios, QPS has a drop of about 10% (from 11000/s to 10000/s)
But I think its OK for most cases.


private long maxConn = 100;

private long maxQueryInstances = -1;
Copy link
Contributor

Choose a reason for hiding this comment

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

We can create a new class and put all user property in it. And using json to serialize it. So that we don't need to update the meta version each time we add a new property in future.

@morningman morningman added kind/feature Categorizes issue or PR as related to a new feature. resource-limit labels Jul 6, 2021
@liutang123 liutang123 force-pushed the max_query_instances branch from 1e34672 to 307c47f Compare July 7, 2021 16:18
@morningman morningman added the kind/meta-version-change Categorizes issue or PR as related to changing meta version label Jul 9, 2021
Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

@morningman morningman merged commit b5f447b into apache:master Jul 10, 2021
@ccoffline ccoffline mentioned this pull request Sep 8, 2021
13 tasks
@morningman morningman mentioned this pull request Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. kind/meta-version-change Categorizes issue or PR as related to changing meta version resource-limit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add user property to limit the instance num

2 participants