Closed KiLLeRRaT closed 4 years ago
I am having the same issue, run HA/SQL in Docker containers, just started with 0.108.x
I am seeing this issue as well. Run SQL on a separate VM. Also saw this start with 0.108.x.
I am having the same issue, run HA/SQL in Docker containers, just started with 0.108.x
I added autocommit=True;
to my recorder pyodbc connection string and the errors went away. I am fine with no client side transaction management and allowing transactions to commit automatically but you may not be.
When autocommit is set to True, the database executes a commit automatically after every SQL statement, so transaction management by the client is not possible. Note, those automatic commits are executed by the database itself, not pyodbc, i.e. the database essentially runs every SQL statement within its own transaction. pyodbc Documentation
Got this too. That autocommit sounds good. I need to try that.
On the investigation I also noticed that Google Cast integration have started to update state 7 times per second when watching something from Android TV. That resulted 26000 additional records per hour which might have given some issues for the db as well. 😅 It was updating media location attribute all the time. Now I have excluded that from recorder.
Normally I'm getting in average about 4000 records per hour.
I added autocommit true a few weeks ago and it's been rock solid since, state history loads quickly etc. I'm not too bothered about wrapping stuff up in transactions, I'd rather HASS stays fast.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
The problem
After upgrading to from 0.107 to 0.108 (any of those versions) I satrted noticing very high SQL Server CPU usage. Running
SP_WHO2
shows blocking transactions. I also found the below errors with deadlocks, as well asCOMMIT TRANSACTION
without aBEGIN TRANSACTION
.I have a question related to this. Is there a way I can specify
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
for my SQL Connection? That would keep all my reads working (I don't mind about dirty reads for states/events) and they won't be blocked by anything trying to write.Note that you will find I'm not purging logs in the config. I manually handle my own purging on a nightly job.
Environment
Problem-relevant
configuration.yaml
Traceback/Error logs
Additional information