Change minimum SQLite version to 3.40.1 (#135042)

Co-authored-by: J. Nick Koston <nick@koston.org>
pull/135162/head
G Johansson 2025-01-09 03:34:36 +01:00 committed by GitHub
parent c5f80dd01d
commit 64752af4c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 125 deletions

View File

@ -16,10 +16,6 @@
"backup_failed_out_of_resources": {
"title": "Database backup failed due to lack of resources",
"description": "The database backup stated at {start_time} failed due to lack of resources. The backup cannot be trusted and must be restarted. This can happen if the database is too large or if the system is under heavy load. Consider upgrading the system hardware or reducing the size of the database by decreasing the number of history days to keep or creating a filter."
},
"sqlite_too_old": {
"title": "Update SQLite to {min_version} or later to continue using the recorder",
"description": "Support for version {server_version} of SQLite is ending; the minimum supported version is {min_version}. Please upgrade your database software."
}
},
"services": {

View File

@ -95,9 +95,8 @@ RECOMMENDED_MIN_VERSION_MARIA_DB_108 = _simple_version("10.8.4")
MARIADB_WITH_FIXED_IN_QUERIES_108 = _simple_version("10.8.4")
MIN_VERSION_MYSQL = _simple_version("8.0.0")
MIN_VERSION_PGSQL = _simple_version("12.0")
MIN_VERSION_SQLITE = _simple_version("3.31.0")
UPCOMING_MIN_VERSION_SQLITE = _simple_version("3.40.1")
MIN_VERSION_SQLITE_MODERN_BIND_VARS = _simple_version("3.32.0")
MIN_VERSION_SQLITE = _simple_version("3.40.1")
MIN_VERSION_SQLITE_MODERN_BIND_VARS = _simple_version("3.40.1")
# This is the maximum time after the recorder ends the session
@ -376,37 +375,6 @@ def _raise_if_version_unsupported(
raise UnsupportedDialect
@callback
def _async_delete_issue_deprecated_version(
hass: HomeAssistant, dialect_name: str
) -> None:
"""Delete the issue about upcoming unsupported database version."""
ir.async_delete_issue(hass, DOMAIN, f"{dialect_name}_too_old")
@callback
def _async_create_issue_deprecated_version(
hass: HomeAssistant,
server_version: AwesomeVersion,
dialect_name: str,
min_version: AwesomeVersion,
) -> None:
"""Warn about upcoming unsupported database version."""
ir.async_create_issue(
hass,
DOMAIN,
f"{dialect_name}_too_old",
is_fixable=False,
severity=ir.IssueSeverity.CRITICAL,
translation_key=f"{dialect_name}_too_old",
translation_placeholders={
"server_version": str(server_version),
"min_version": str(min_version),
},
breaks_in_ha_version="2025.2.0",
)
def _extract_version_from_server_response_or_raise(
server_response: str,
) -> AwesomeVersion:
@ -523,20 +491,6 @@ def setup_connection_for_dialect(
version or version_string, "SQLite", MIN_VERSION_SQLITE
)
# No elif here since _raise_if_version_unsupported raises
if version < UPCOMING_MIN_VERSION_SQLITE:
instance.hass.add_job(
_async_create_issue_deprecated_version,
instance.hass,
version or version_string,
dialect_name,
UPCOMING_MIN_VERSION_SQLITE,
)
else:
instance.hass.add_job(
_async_delete_issue_deprecated_version, instance.hass, dialect_name
)
if version and version > MIN_VERSION_SQLITE_MODERN_BIND_VARS:
max_bind_vars = SQLITE_MODERN_MAX_BIND_VARS

View File

@ -35,7 +35,6 @@ from homeassistant.components.recorder.models import (
from homeassistant.components.recorder.util import (
MIN_VERSION_SQLITE,
RETRYABLE_MYSQL_ERRORS,
UPCOMING_MIN_VERSION_SQLITE,
database_job_retry_wrapper,
end_incomplete_runs,
is_second_sunday,
@ -236,7 +235,7 @@ def test_setup_connection_for_dialect_mysql(mysql_version) -> None:
@pytest.mark.parametrize(
"sqlite_version",
[str(UPCOMING_MIN_VERSION_SQLITE)],
[str(MIN_VERSION_SQLITE)],
)
def test_setup_connection_for_dialect_sqlite(sqlite_version: str) -> None:
"""Test setting up the connection for a sqlite dialect."""
@ -289,7 +288,7 @@ def test_setup_connection_for_dialect_sqlite(sqlite_version: str) -> None:
@pytest.mark.parametrize(
"sqlite_version",
[str(UPCOMING_MIN_VERSION_SQLITE)],
[str(MIN_VERSION_SQLITE)],
)
def test_setup_connection_for_dialect_sqlite_zero_commit_interval(
sqlite_version: str,
@ -510,11 +509,11 @@ def test_supported_pgsql(caplog: pytest.LogCaptureFixture, pgsql_version) -> Non
[
(
"3.30.0",
"Version 3.30.0 of SQLite is not supported; minimum supported version is 3.31.0.",
"Version 3.30.0 of SQLite is not supported; minimum supported version is 3.40.1.",
),
(
"2.0.0",
"Version 2.0.0 of SQLite is not supported; minimum supported version is 3.31.0.",
"Version 2.0.0 of SQLite is not supported; minimum supported version is 3.40.1.",
),
],
)
@ -552,8 +551,8 @@ def test_fail_outdated_sqlite(
@pytest.mark.parametrize(
"sqlite_version",
[
("3.31.0"),
("3.33.0"),
("3.40.1"),
("3.41.0"),
],
)
def test_supported_sqlite(caplog: pytest.LogCaptureFixture, sqlite_version) -> None:
@ -734,63 +733,6 @@ async def test_no_issue_for_mariadb_with_MDEV_25020(
assert database_engine.optimizer.slow_range_in_select is False
async def test_issue_for_old_sqlite(
hass: HomeAssistant,
issue_registry: ir.IssueRegistry,
) -> None:
"""Test we create and delete an issue for old sqlite versions."""
instance_mock = MagicMock()
instance_mock.hass = hass
execute_args = []
close_mock = MagicMock()
min_version = str(MIN_VERSION_SQLITE)
def execute_mock(statement):
nonlocal execute_args
execute_args.append(statement)
def fetchall_mock():
nonlocal execute_args
if execute_args[-1] == "SELECT sqlite_version()":
return [[min_version]]
return None
def _make_cursor_mock(*_):
return MagicMock(execute=execute_mock, close=close_mock, fetchall=fetchall_mock)
dbapi_connection = MagicMock(cursor=_make_cursor_mock)
database_engine = await hass.async_add_executor_job(
util.setup_connection_for_dialect,
instance_mock,
"sqlite",
dbapi_connection,
True,
)
await hass.async_block_till_done()
issue = issue_registry.async_get_issue(DOMAIN, "sqlite_too_old")
assert issue is not None
assert issue.translation_placeholders == {
"min_version": str(UPCOMING_MIN_VERSION_SQLITE),
"server_version": min_version,
}
min_version = str(UPCOMING_MIN_VERSION_SQLITE)
database_engine = await hass.async_add_executor_job(
util.setup_connection_for_dialect,
instance_mock,
"sqlite",
dbapi_connection,
True,
)
await hass.async_block_till_done()
issue = issue_registry.async_get_issue(DOMAIN, "sqlite_too_old")
assert issue is None
assert database_engine is not None
@pytest.mark.skip_on_db_engine(["mysql", "postgresql"])
@pytest.mark.usefixtures("skip_by_db_engine")
async def test_basic_sanity_check(

View File

@ -121,15 +121,6 @@ def disable_mariadb_issue() -> None:
yield
@pytest.fixture(autouse=True)
def disable_sqlite_issue() -> None:
"""Disable creating issue about outdated SQLite version."""
with patch(
"homeassistant.components.recorder.util._async_create_issue_deprecated_version"
):
yield
async def async_list_statistic_ids(
hass: HomeAssistant,
statistic_ids: set[str] | None = None,