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

state.db-wal grown too large #1575

Closed
VladoPortos opened this issue Mar 24, 2020 · 6 comments
Closed

state.db-wal grown too large #1575

VladoPortos opened this issue Mar 24, 2020 · 6 comments
Assignees
Labels
priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.

Comments

@VladoPortos
Copy link

Any idea what is in state.db-wal ?
It grown to 8+GB within a month or so... is it something that can be cleaned up, or how can I find out why it is filling up so much ?

@clook
Copy link

clook commented Apr 13, 2020

I had the same issue (16 GB file, leading to pod eviction).
I could vacuum the following way without problem (not sure how safe it is though):

systemctl stop k3s
sqlite3 /var/lib/rancher/k3s/server/db/state.db
sqlite> vacuum;
sqlite> .quit
# The file  /var/lib/rancher/k3s/server/db/state.db-wal is not there anymore, k3s kine sqlite driver will recreate it.
systemctl start k3s

If the vacuum has to be implemented, a specific issue should imo go there: https://github.com/rancher/kine

@Locus99
Copy link

Locus99 commented Jun 26, 2020

I had a similar situation where the file got to an amazing 177GB in size. Running those commands got rid of that file. Will follow up if there are any issues from running the commands.

@brandond
Copy link
Member

brandond commented Oct 27, 2020

We should probably evaluate either enabling auto-vacuum, or manually vacuuming at intervals or at startup since auto-vacuum cannot be enabled on existing databases.

https://sqlite.org/lang_vacuum.html

@brandond
Copy link
Member

brandond commented Nov 5, 2020

For anyone encountering this in the future - could you comment here? We'd like to know more about the workload and collect some statistics from your database.

In particular, using the Precompiled Binaries for Linux from https://www.sqlite.org/download.html, run:

./sqlite3_analyzer /var/lib/rancher/k3s/server/db/state.db
./sqlite3 /var/lib/rancher/k3s/server/db/state.db << EOF
.header on
.mode column
.dbinfo

SELECT 
  COUNT(*) AS rows, 
  (SELECT prev_revision FROM kine WHERE name = "compact_rev_key" LIMIT 1) AS compact_rev,
  MAX(id) AS current_rev
FROM kine;

SELECT COUNT(*), name FROM kine GROUP BY name ORDER BY COUNT(*) DESC LIMIT 50;

EOF

@dweomer dweomer added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Nov 23, 2020
@brandond
Copy link
Member

Closing this issue as it does not appear to be affecting anyone any longer. If someone does run into this, please collect information on the sqlite database as described above and open a new issue.

@andrewwebber
Copy link

andrewwebber commented Sep 21, 2021

Unfortunately I experience this issue on K3OS on AWS. Due to the minimal OS it is difficult to execute sqlite3 on the host.

I have made the following workaround for anyone on K3OS or a minimum / cloud OS

https://github.com/andrewwebber/k3os-db-vacuum

@k3s-io k3s-io locked as resolved and limited conversation to collaborators Sep 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

No branches or pull requests

7 participants