-
Notifications
You must be signed in to change notification settings - Fork 881
feat(coderd/database): keep only 1 day of workspace_agent_stats
after rollup
#12674
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
77ba7dc
to
754fdd5
Compare
5024af0
to
9286a28
Compare
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.
Is there a maximum number of rows that could be deleted here?
Would it make sense to add a limit on the number of rows deleted?
My thinking is that we could choose a reasonably large upper limit and hopefully converge after a few iterations.
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.
Not a bad idea. Limiting would only be relevant for the first time(s) this query runs, after that there's no point but if we want to avoid the initial performance penalty of doing a huge delete, that would be sensible. There's no limit for deletes though so we could rely on selecting the min(created_at) and only delete 1 (or N days) of data.
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.
I thinking deleting the oldest day of data every interval will probably work fine here. The magnitude of that data should scale with the size of the deployment. We'll have to assume that the database is correctly sized to handle that level of deletes, but if not that is likely a sizing issue with the database itself in relation to the rest of the deployment.
754fdd5
to
7128953
Compare
9286a28
to
95cdaca
Compare
created_at < ( | ||
SELECT | ||
COALESCE( | ||
-- When generating initial template usage stats, all the |
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 change may be little too soon to drop. If customers identify problems with the release, they will decide to roll back to the previous version. Boom! No workspace_agent_stats
anymore.
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.
I agree, I made this a separate PR so we can defer it for later.
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.
Rollbacks require db backups at present. We just do not support downgrades at present.
And not supported like, you can't even really do it. You have to run the migration downgrade
with the latest version, then rollback. We have 0 documentation for this, so no customer should do it.
workspace_agent_stats
after rollupworkspace_agent_stats
after rollup
7128953
to
b915c4c
Compare
95cdaca
to
8a2d9f8
Compare
1477d70
to
d982c5b
Compare
8a2d9f8
to
ad2b3e7
Compare
d982c5b
to
71cd6ff
Compare
ad2b3e7
to
8442baa
Compare
71cd6ff
to
fb7f72c
Compare
8442baa
to
563ad78
Compare
6c31bbb
to
364b21e
Compare
140017a
to
eb01ba5
Compare
364b21e
to
3e356f2
Compare
eb01ba5
to
1ef1513
Compare
3e356f2
to
ccb914c
Compare
1ef1513
to
e720b91
Compare
ccb914c
to
1489cd6
Compare
1489cd6
to
859f9d4
Compare
859f9d4
to
89ecbf2
Compare
@johnstcn I've added the batch deleting in case you want to take a look. |
89ecbf2
to
b5b95d2
Compare
workspace_agent_stats
after rollupworkspace_agent_stats
after rollup
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.
just needs a make gen
b5b95d2
to
18b45c2
Compare
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 will free up many gigabytes of data for many customers, more for those that have a lot of workspaces running daily.
Refs #12122