diff --git a/backend/services/navi_offroute/hpa_manifest.py b/backend/services/navi_offroute/hpa_manifest.py index 19d732a..48d794c 100644 --- a/backend/services/navi_offroute/hpa_manifest.py +++ b/backend/services/navi_offroute/hpa_manifest.py @@ -10,9 +10,8 @@ neither env var set -> HPA disabled (same as today). import json import logging import os -import sqlite3 from dataclasses import dataclass, field -from typing import Dict, List, Optional +from typing import List, Optional logger = logging.getLogger(__name__) @@ -43,10 +42,8 @@ class TileDBEntry: @dataclass class HPAManifest: - """Registry of regional tile DBs + lazy per-path sqlite connection cache. - The cache is process-local mutable state; entries are immutable after load.""" + """Registry of regional tile DBs. Immutable after load.""" entries: List[TileDBEntry] = field(default_factory=list) - _conns: Dict[str, sqlite3.Connection] = field(default_factory=dict) def enabled(self) -> bool: return len(self.entries) > 0 @@ -73,17 +70,6 @@ class HPAManifest: return self.dbs_for_chunks(min(cx0, cx1), max(cx0, cx1), min(cy0, cy1), max(cy0, cy1)) - def get_connection(self, abs_path: str) -> sqlite3.Connection: - """Read-only sqlite connection cached for the life of the process. v1 - dispatch (astar_hpa_multimode) opens its own connection per call and does - not yet use this cache; multi-region UNION + admin endpoints will.""" - conn = self._conns.get(abs_path) - if conn is None: - conn = sqlite3.connect(f"file:{abs_path}?mode=ro", uri=True) - self._conns[abs_path] = conn - return conn - - # ── loaders ────────────────────────────────────────────────────────────────── def _load_from_dir(dir_path: str) -> HPAManifest: diff --git a/backend/services/navi_offroute/tests/test_hpa_manifest.py b/backend/services/navi_offroute/tests/test_hpa_manifest.py index 85d17a4..6013242 100644 --- a/backend/services/navi_offroute/tests/test_hpa_manifest.py +++ b/backend/services/navi_offroute/tests/test_hpa_manifest.py @@ -106,12 +106,3 @@ def test_load_env_disabled_paths(tmp_path, monkeypatch): # neither var set -> empty monkeypatch.delenv(hm.ENV_LEGACY, raising=False) assert not hm.load().enabled() - - -def test_get_connection_caches_per_path(tmp_path): - import sqlite3 - p = _touch(str(tmp_path), "x.db") - with sqlite3.connect(p) as c: - c.execute("CREATE TABLE t (x INTEGER)") - m = hm.HPAManifest(entries=[hm.TileDBEntry("x", p, None)]) - assert m.get_connection(p) is m.get_connection(p)