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

feat: remove duplicate queries during settings flow and use better index hint for credentials lookup #4193

Merged
merged 23 commits into from
Nov 7, 2024

Conversation

aeneasr
Copy link
Member

@aeneasr aeneasr commented Nov 5, 2024

This patch reduces duplicate GetIdentity queries as part of submitting the settings flow, and improves an index to significantly reduce credential lookup.

For better debugging, more tracing ha been added to the settings module.

Related issue(s)

Checklist

  • I have read the contributing guidelines.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I am following the
    contributing code guidelines.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security vulnerability, I
    confirm that I got the approval (please contact
    [email protected]) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added or changed the documentation.

Further Comments

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 74.50199% with 64 lines in your changes missing coverage. Please review.

Project coverage is 78.60%. Comparing base (215af57) to head (8087a0e).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
selfservice/strategy/oidc/strategy_settings.go 61.22% 18 Missing and 1 partial ⚠️
selfservice/flow/settings/error.go 64.51% 7 Missing and 4 partials ⚠️
selfservice/flow/settings/handler.go 77.41% 4 Missing and 3 partials ⚠️
selfservice/flow/settings/hook.go 79.31% 4 Missing and 2 partials ⚠️
selfservice/strategy/totp/settings.go 71.42% 4 Missing and 2 partials ⚠️
selfservice/strategy/lookup/settings.go 75.00% 2 Missing and 1 partial ⚠️
selfservice/strategy/password/settings.go 72.72% 2 Missing and 1 partial ⚠️
selfservice/strategy/webauthn/settings.go 81.25% 2 Missing and 1 partial ⚠️
persistence/sql/identity/persister_identity.go 66.66% 0 Missing and 2 partials ⚠️
selfservice/strategy/link/strategy_recovery.go 75.00% 1 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4193      +/-   ##
==========================================
+ Coverage   78.52%   78.60%   +0.07%     
==========================================
  Files         380      380              
  Lines       27176    27128      -48     
==========================================
- Hits        21340    21324      -16     
+ Misses       4215     4189      -26     
+ Partials     1621     1615       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aeneasr aeneasr force-pushed the remove-superfluous-session-fetch branch from dfdc9bb to 8a3266e Compare November 6, 2024 13:31
@aeneasr aeneasr changed the title feat: load session only once when middleware is used feat: remove duplicate queries during settings flow and use better index hint for credentials lookup Nov 6, 2024
@@ -806,11 +806,11 @@ func identifiersTableNameWithIndexHint(con *pop.Connection) string {
ici := "identity_credential_identifiers"
switch con.Dialect.Name() {
case "cockroach":
ici += "@identity_credential_identifiers_nid_i_ici_idx"
ici += "@identity_credential_identifiers_nid_ici_i_idx"
Copy link
Member Author

@aeneasr aeneasr Nov 6, 2024

Choose a reason for hiding this comment

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

@alnr the old index is not dropped yet (identity_credential_identifiers_nid_i_ici_idx), will be done in the next release

@@ -0,0 +1,4 @@
CREATE INDEX IF NOT EXISTS identity_credential_identifiers_ici_nid_i_idx
ON identity_credential_identifiers (identity_credential_id ASC, nid ASC, identifier ASC);
Copy link
Member Author

Choose a reason for hiding this comment

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

@alnr i changed the index structure to use identity_credential_id as the prefix (it is also the highest cardinality) and then we can use it both for FK and the query credentials

@@ -199,23 +205,20 @@ func (e *HookExecutor) PostSettingsHook(w http.ResponseWriter, r *http.Request,
case "oidc":
group = node.OpenIDConnectGroup
}
var traits identity.Traits
if i != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

i is never nil

@aeneasr aeneasr merged commit c33965e into master Nov 7, 2024
26 of 29 checks passed
@aeneasr aeneasr deleted the remove-superfluous-session-fetch branch November 7, 2024 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant