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: reduce number of iops on postgresql engines #3289

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

lunar-smh
Copy link
Contributor

@lunar-smh lunar-smh commented Oct 10, 2022

Optimise SQL update to avoid redundant writes, which may lead to a high number of iops on postgresql engines.
This change will not change the behaviour of the code. It is only an optimisation of the update, so Postgresql does not need to spend unneccessary resources on vaccuming. I assume that the actual update is going to perform slightly better as well.

fixes #3137

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. Yes, I have read this one: SECURITY.md
  • 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
    security@ory.sh) 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

fixes ory#3137 - The SQL update here would potentially update a lot of rows, which did not need updating. In some DB engines, this would not be an issue, because the redundant writes are ignored. But on PostgreSQL engines, it is another story; here it would actually carry out the writes, leading to a potentially high number of redundant iops when the engine is vaccuming outdated records. With this change, the SQL update will only affect the rows which is not in the desired state already.
@lunar-smh lunar-smh changed the title Reduce number of iops on postgresql engines fix: Reduce number of iops on postgresql engines Oct 10, 2022
@lunar-smh lunar-smh changed the title fix: Reduce number of iops on postgresql engines fix: reduce number of iops on postgresql engines Oct 10, 2022
@codecov
Copy link

codecov bot commented Oct 10, 2022

Codecov Report

Merging #3289 (ae94fba) into master (8b8e73d) will decrease coverage by 1.51%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3289      +/-   ##
==========================================
- Coverage   78.42%   76.91%   -1.52%     
==========================================
  Files         123      123              
  Lines       12518     8918    -3600     
==========================================
- Hits         9817     6859    -2958     
+ Misses       2061     1631     -430     
+ Partials      640      428     -212     
Impacted Files Coverage Δ
persistence/sql/persister_oauth2.go 82.12% <100.00%> (-5.51%) ⬇️
consent/subject_identifier_algorithm_pairwise.go 37.50% <0.00%> (-14.89%) ⬇️
jwk/cast.go 61.90% <0.00%> (-13.86%) ⬇️
x/secret.go 80.00% <0.00%> (-13.75%) ⬇️
driver/registry.go 24.24% <0.00%> (-12.35%) ⬇️
cmd/version.go 44.44% <0.00%> (-10.11%) ⬇️
spec/config.go 40.00% <0.00%> (-10.00%) ⬇️
jwk/jwt_strategy.go 56.66% <0.00%> (-10.00%) ⬇️
cmd/cmd_import_jwk.go 67.53% <0.00%> (-8.40%) ⬇️
driver/config/tls.go 85.71% <0.00%> (-7.91%) ⬇️
... and 114 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@lunar-smh
Copy link
Contributor Author

I do not understand why Codecov thinks that my change will reduce coverage by 1,51%
Any help to understand the feedback and how to handle it, is much appreciated.

@lunar-smh lunar-smh marked this pull request as ready for review October 10, 2022 11:19
Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Nice find!

@aeneasr aeneasr merged commit 1aa6cc4 into ory:master Oct 10, 2022
@lunar-smh
Copy link
Contributor Author

@aeneasr Thank you for reviewing and accepting my PR.
Do you have idea when it might be released?

@aeneasr
Copy link
Member

aeneasr commented Oct 11, 2022

We will release Hydra 2.0 at the summit

@vinckr
Copy link
Member

vinckr commented Oct 12, 2022

Hello @lunar-smh
Congrats on merging your first PR in Ory 🎉 !
Your contribution will soon be helping secure millions of identities around the globe 🌏.
As a small token of appreciation we send all our first time contributors a gift package to welcome them to the community.
Please drop me an email and I will forward you the form to claim your Ory swag!

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.

Autovacuum takes hours on PostgreSQL
3 participants