-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: fix performance regression in user authn #58671
Conversation
I applied this patch to 20.2.3 and tested on a multi-region cluster and confirmed better login latencies. Not sure how/if to test in unit tests. |
Can we add something to the |
We have a thing for this. Add a benchmark for the "ddl_analyis". I'll unskip the verification part of that too. It's a bad name. It has nothing to do with DDL. Grr. got sniped by jordan's stream and didn't submit this until lucy got there. |
Awesome! will work on those tests then. See #58674 for follow-up work |
i wrote a new benchmark under I've added logging and confirmed it does descriptor lookups in cockroach/pkg/bench/ddl_analysis/ddl_analysis_bench.go Lines 104 to 108 in f0b5774
The test cases look like this
|
You may need help from @ajwerner for the ddl_analysis test. Then, separately, can you please file an issue to also add a |
@knz I'm getting help from @RichardJCai who wrote the benchmarks and just re-joined us today. I can file such an issue, though my initial thought was to not do that since it would be rather tedious to fix, and also not future-proof, as someone could quite easily add another system query that doesn't specify the schema. That's why I created this change instead: #58674 |
oh cool that works too. carry on then |
d108784
to
aa8925c
Compare
The authn code needs to query system.users and system.role_options. These queries are run by the internal executor, which has a current DB of "". This causes the name to be resolved as "".system.users and "".system.role_options. The lookup for the "" DB always fails, but that result is not cached, so the lookup occurs on every authn attempt. There is fallback logic that then looks up the correct name. Now we specify the fully-qualified 3-part name for these two queries. To show that this fix is important, new benchmarks are added to the bench/ddl_analysis tests. Release note (bug fix): The user authentication flow no longer performs extraneous name lookups. This performance regression was present since v20.2.
aa8925c
to
4106e33
Compare
bors r=otan |
Build succeeded: |
The authn code needs to query system.users and system.role_options.
These queries are run by the internal executor, which has a current DB
of "". This causes the name to be resolved as "".system.users and
"".system.role_options. The lookup for the "" DB always fails, but that
result is not cached, so the lookup occurs on every authn attempt. There
is fallback logic that then looks up the correct name.
Now we specify the fully-qualified 3-part name for these two queries.
This is a low-risk change that can be backported. A more robust fix that
will prevent this class of mistaken lookups will follow later, but probably
can't be backported.
Release note (bug fix): The user authentication flow no longer performs
extraneous name lookups. This performance regression was present since
v20.2.