-
Notifications
You must be signed in to change notification settings - Fork 109
Fix: Delete old sessions in cleanup cron #7665
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
Conversation
Signed-off-by: Benjamin Frueh <[email protected]>
Signed-off-by: Benjamin Frueh <[email protected]>
Signed-off-by: Benjamin Frueh <[email protected]>
Signed-off-by: Benjamin Frueh <[email protected]>
mejo-
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this! @max-nextcloud and me discussed this PR and think it's good to merge (except for the nitpicking comment 😆).
Deleting sessions is not very intrusive as the frontend will merely suggest a reload to the user if the session got removed server-side.
The thread of data loss is very minor as that would be only editing steps that exist in the frontend and were not synchronized to the server yet. Since steps get send immediately and we currently set the editor to read-only once sending steps failed for some seconds, it can only be seconds of editing changes to the document.
Signed-off-by: Benjamin Frueh <[email protected]>
|
@mejo- and @max-nextcloud I did make some changes shortly before your comment and pushed them. I changed the variable names to be consistent and also for safety added logic so sessions containing step ids >= last_saved_version are never deleted. Could you review those changes and let me know if there are further todos. I also adjusted the tests accordingly. |
|
Thanks @benjaminfrueh, much appreciated!
I don't think that's necessary and would be in favour of reverting this change. As @max-nextcloud explained in his comment to your other PR, sessions are bound to a specific client. They're more or less merely the authentication token created when a client joins an editing session. Any client with an active session will autosave the document every thirty seconds, what incorporates all steps into the saved document and bumps |
|
HI @mejo-, thanks again for the detailed feedback. That makes total sense, in this case it should be save to delete any session which is older than the defined threshhold of currently 90 days. I did revert the recent change and added a seperate commit for the variable name consistency. |
max-nextcloud
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good to go now from my side (besides the missing signoff on the revert that shows in the CI checks). Thanks a lot for tackling this.
This reverts commit 1dc1cba. Signed-off-by: Benjamin Frueh <[email protected]>
Signed-off-by: Benjamin Frueh <[email protected]>
a1eb1dd to
594bf8b
Compare
|
@max-nextcloud missing sign-off for revert commit is added now |
mejo-
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I just spotted that the PR still has logic to clean up steps, which should be reverted as well.
lib/Db/SessionMapper.php
Outdated
| break; | ||
| } | ||
|
|
||
| $deleteStepsQb = $this->db->getQueryBuilder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This delete query should be removed. As explained earlier, we don't want to delete the steps from sessions that got deleted. This task should really merely remove sessions older than 90 days as they will be recreated easily without data loss. Removing steps more or less unconditionally on the other hand might result in data loss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, in the recent commit I removed the step deletion part from the deleteOldSessions function.
Signed-off-by: Benjamin Frueh <[email protected]>
mejo-
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, now all good to go 🎉
|
@benjaminfrueh except for the now failing test 🙈 😆 |
…ted, not their steps Signed-off-by: Benjamin Frueh <[email protected]>
Test is updated now, thanks again for the review! |
|
/backport to stable32 |
|
/backport to stable31 |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
|
/backport to stable32 |
|
The backport to # Switch to the target branch and update it
git checkout stable32
git pull origin stable32
# Create the new backport branch
git checkout -b backport/7665/stable32
# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick 6687601b 10ab5b56 d866c001 54fb2ef4 1dc1cba7 ebaf60f7 594bf8b4 b1afd239 3665ce75
# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/7665/stable32Error: Failed to check for changes with origin/stable32: No changes found in backport branch Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports. |
📝 Summary
The oc_text_steps table was growing significantly. This adds a step to the cleanup cron which deletes sessions with their steps older than 90 days. The sessions are deleted in batches of 1000 and the execution is time-limited for 30 seconds.
🏁 Checklist
npm run lint/npm run stylelint/composer run cs:check)