-
Notifications
You must be signed in to change notification settings - Fork 254
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
How to cleanup a Kine sqlite DB ? #213
Comments
You didn't fill out the issue template, so I have to ask - what version of k3s are you on? |
sorry (but there was no issue template to select when creating a "New issue") I'm running the latest stable version of k3s:
Running on RaspberryPi OS, 64 Bit. |
Naively deleting leases with the same revision number except for the latest didn't help, I now get tons of other errors (playing back my backup now). |
Ah, because this issue was probably best asked in the k3s repo, since you're using kine embedded in k3s. We have several issue templates there that ask for relevant information. Check your k3s journald logs for message that look like these, once every 5 minutes:
If you don't see those, and see an error instead, then for some reason your compaction is failing.
Yeah, don't do that. You'd want to shut down k3s and use the sqlite standalone binary to run a manual compact query: delete from kine where id in (select id from (select id, name from kine where id not in (select max(id) as id from kine group by name))); |
Thanks for the quick feedback! Indeed, I see something like:
|
Running now your proposed cleanup statement, vacuum and then will try again. 'will report back, but might take a bit :-) |
@brandond, that helped! I have now back from 4.9 GB to 62 MB and to 20k entries only. My takeaways for this are:
|
Unfortunately I'm not completely done, because my original issue was that an invalid CR broke the K8s garbage collection loop, so that a tons of completed job and pod objects piled up (from a 5min cron-job) that never get garbage collected. I just noticed it when there were over 2k of those jobs. I've delete them, but they are still contained in the sqlitedb (3.5k rows for jobs & pods) and now they re-appear as zombies in the journal log with:
There are no corresponding Jobs resources in
Sorry to bother you with this, I know its not originally a kine issue. Feel free to close the issue if this completely off. |
But maybe you can help me with the question of what "k8s" as |
Deleted resources will get cleaned up by compaction eventually. The actual compact query run internally is slightly more complex and includes deleted objects. We're you able to find the log messages regarding compaction? How long is it currently taking? |
@brandond that is all I've found wrt/ compaction: #213 (comment) and as you can see, it ran into a timeout. (that is what I meant, that the compaction itself ran into a transaction timeout during the delete, which means that from that point on no compaction works anymore because only compaction reduces the data size leading potentially in shorter query times that would fit again into the allowed transaction time) I think I'm finally good after a lot of trial and error (also getting rid of some container zombies as described in k3s-io/k3s#6185 (comment)) and the cronjob and its enqueue pods). Thanks again for your support, the manual compaction statement from above to get from 600k to 20k entries was absolute key to getting back into a usable state. |
Right, I was hoping to hear whether or not you're getting the same errors after running manual compaction, or what the new elapsed time is if compaction is succeeding. If you are still seeing the automatic compact fail, you'll just run into problems again further down the road - if compaction fails regularly, the database will continue to grow until it is multiple GB again. |
Ah, ok. No, after the manual compaction, the regular compaction works as expected again:
It was only the transaction timeout (because of a too-large DB, manual compaction took also around 15 minutes) which broke the compaction. |
OK, great. That's what I was hoping to see. FWIW, kine will also run a vacuum at startup, so as long as compaction is working and you restart k3s periodically, the database should stay pretty small. |
This comment was marked as off-topic.
This comment was marked as off-topic.
You're commenting on an issue about sqlite, but you're not running sqlite. If you're using an external DB, check the K3s log messages about compaction, and make sure that your database is able to keep up with compact requests, otherwise it'll fill as you are seeing. Please take any further conversation about this to a new issue. |
I have successfully used K3s with a sqlite backend for now 3.5 years constantly on a Raspberry Pi 4 cluster.
Just recently I have sever performance issues with "Slow SQL" queries. Looking into the database I see
I don't think that that many revision of one objects are expected to be here (the leases have all the same 'create_revision' value, but different 'prev_revision' values).
My question: Can I remove all except one at least from the leases ? And why are so many revisions kept like e.g. for the DaemonSets ?
The overall sqlite DB is 4.9 GB in size now, with 640k rows in table 'kine'
The text was updated successfully, but these errors were encountered: