-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Janitor does not clean up the sessions #2561
Comments
It seems to me that the values in
The problem I see here is that |
True, we don't keep that around. I think we should add that field to the table! Does the table have any foreign keys on e.g. login or consent requests? |
Ok, I don't remember if the constraint is cascade delete or cascade set null. If it is the latter, this table would be safe for purging old records |
It seems that it cascades deletes:
|
I think we can delete the sessions with select s.id
from hydra_oauth2_authentication_session s,
hydra_oauth2_authentication_request r,
hydra_oauth2_authentication_request_handled h
where s.id = r.login_session_id
and r.challenge = h.challenge
and h.remember = 1
and now() - h.requested_at > h.remember_for; |
The problem with the proposed query is that it would delete login session, which deletes authentication session, which deletes (I think) consent session, which deletes access tokens. So while the login session might be expired, it could still bel inked to an access token. This connection must be kept alive for the OIDC Front/Back-channel logouts to work. Thus, I think that we can only safely delete all sessions that do not have foreign key references. If they do have foreign key references, it means they are still used. Foreign keys references should be removed by the current janitor already. What we would need however would be a |
Deletes from But you are right, sessions are not useful without I created a draft PR. Please have a look and let me know what you think about it. I can add more tests if it is needed. |
One issue with the current implementation is this line: hydra/persistence/sql/persister_consent.go Line 490 in 0dda22d
It should probably use |
Hello contributors! I am marking this issue as stale as it has not received any engagement from the community or maintainers a year. That does not imply that the issue has no merit! If you feel strongly about this issue
Throughout its lifetime, Ory has received over 10.000 issues and PRs. To sustain that growth, we need to prioritize and focus on issues that are important to the community. A good indication of importance, and thus priority, is activity on a topic. Unfortunately, burnout has become a topic of concern amongst open-source projects. It can lead to severe personal and health issues as well as opening catastrophic attack vectors. The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone. If this issue was marked as stale erroneous you can exempt it by adding the Thank you for your understanding and to anyone who participated in the conversation! And as written above, please do participate in the conversation if this topic is important to you! Thank you 🙏✌️ |
so this has stalled? I really would need to clean up those sessions ... There are millions of rows there on a relatively small site. |
Hello contributors! I am marking this issue as stale as it has not received any engagement from the community or maintainers for a year. That does not imply that the issue has no merit! If you feel strongly about this issue
Throughout its lifetime, Ory has received over 10.000 issues and PRs. To sustain that growth, we need to prioritize and focus on issues that are important to the community. A good indication of importance, and thus priority, is activity on a topic. Unfortunately, burnout has become a topic of concern amongst open-source projects. It can lead to severe personal and health issues as well as opening catastrophic attack vectors. The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone. If this issue was marked as stale erroneously you can exempt it by adding the Thank you for your understanding and to anyone who participated in the conversation! And as written above, please do participate in the conversation if this topic is important to you! Thank you 🙏✌️ |
I noticed that
janitor $DSN --requests
cleans uphydra_oauth2_authentication_request
andhydra_oauth2_consent_request
tables, but nothydra_oauth2_authentication_session
. That latter one is the second largest table in our database right now. It does not seem to be a reason to keep those rows around.Describe the solution you'd like
Remove the rows from
hydra_oauth2_authentication_session
that are no longer needed.hydra_oauth2_authentication_request
orhydra_oauth2_consent_request
Additional context
The two queries to clean up
hydra_oauth2_authentication_request
andhydra_oauth2_consent_request
tables are placed here. It seems fine to me to follow them by a new query to clean up the sessions as well:I think
time.Now().Add(-p.config.ConsentRequestMaxAge())
may not be the right constraint for sessions since they may be useable beyond the lifespan of consent challenges (or am I wrong?) but the rest should be fine.The text was updated successfully, but these errors were encountered: