-
-
Notifications
You must be signed in to change notification settings - Fork 37.5k
Fix recorder with MSSQL #46678
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
Merged
Merged
Fix recorder with MSSQL #46678
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
02a952e
Adjust for MS SQL
bdraco 6512bba
Adjust for MS SQL
bdraco 712231b
Adjust tests
bdraco 78c4d2f
Update homeassistant/components/recorder/purge.py
bdraco c6f36a9
Update homeassistant/components/recorder/purge.py
bdraco 0c6170a
Revert "Update homeassistant/components/recorder/purge.py"
bdraco 41ff99b
switch purge method to be a batch of 5000 events at a time
bdraco e4e3f7f
augment coverage
bdraco c21493b
naming
bdraco dad57b0
use name
bdraco 92e502d
lower rows to purge at once
bdraco 43d6a42
fix postgres vacuum
bdraco 1f67bf8
isolate repack code
bdraco 5894532
Update homeassistant/components/recorder/purge.py
bdraco 84ffc38
typing
bdraco 190ad66
fix typing
bdraco 75efce6
typing
bdraco 90aae2a
remove quotes
bdraco d26b40c
switch tests to utcnow
bdraco 85ffc00
add last_updated
bdraco 811562f
Update homeassistant/components/recorder/purge.py
bdraco ce4eae2
pass purge before
bdraco febbef3
Revert last optimization
cdce8p cbb5173
move const
bdraco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| """Purge repack helper.""" | ||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| if TYPE_CHECKING: | ||
| from . import Recorder | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def repack_database(instance: Recorder) -> None: | ||
| """Repack based on engine type.""" | ||
|
|
||
| # Execute sqlite command to free up space on disk | ||
| if instance.engine.dialect.name == "sqlite": | ||
| _LOGGER.debug("Vacuuming SQL DB to free space") | ||
| instance.engine.execute("VACUUM") | ||
| return | ||
|
|
||
| # Execute postgresql vacuum command to free up space on disk | ||
| if instance.engine.dialect.name == "postgresql": | ||
| _LOGGER.debug("Vacuuming SQL DB to free space") | ||
| with instance.engine.connect().execution_options( | ||
| isolation_level="AUTOCOMMIT" | ||
| ) as conn: | ||
| conn.execute("VACUUM") | ||
| return | ||
|
|
||
| # Optimize mysql / mariadb tables to free up space on disk | ||
| if instance.engine.dialect.name == "mysql": | ||
| _LOGGER.debug("Optimizing SQL DB to free space") | ||
| instance.engine.execute("OPTIMIZE TABLE states, events, recorder_runs") | ||
| return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.