Hi people!
Sorry to bother you with my problem, but… it’s getting really bad in here. Long story short: since 2 weeks ago my HA machine was starting to act really weird (and slow). Then I noticed my mariadb files are getting a ridiculous size increase. Then my VM just crashed (never had that in years of HA use) and I wasn’t able to start it unless I disabled my Bluetooth device (it’s an Intel NUC, with Intel WiFi/Bluetooth Adapter).
And then, when I look in my phpmyadmin, there are entities like this “sensor.ble_mac_50765cb7d9ea4e2199a4fa879613a492” that have more than 20.000.000 entries. Again, in just 2 weeks! I have tried to run the purge service for those entities, but because now my Bluetooth is disabled, I can’t seem to find those entities anywhere, but mariadb/phpmyadmin.
Since I can’t find the entity anywhere, I have tried to delete from phpmyadmin. The command was like this:
delete from states where metadata_id=4166;
But then, after 300s, I get some error “database connection lost”. So I have tried using LIMIT, like this:
delete from states where metadata_id=4166 LIMIT 100;
In response, I get this error:
#1451 - Cannot delete or update a parent row: a foreign key constraint fails (homeassistant.states, CONSTRAINT states_ibfk_2 FOREIGN KEY (old_state_id) REFERENCES states (state_id))
Now, I’m out of ideeas. How can I cleanup my database, by deleting only those states with over 20.000.000 entries?
Thank you in advance!