Skip to content

fix: probe actual GIS capability instead of inferring it from the DB platform - #30

Open
torvalstrom wants to merge 1 commit into
thrillfall:mainfrom
torvalstrom:fix/gis-capability-probe
Open

fix: probe actual GIS capability instead of inferring it from the DB platform#30
torvalstrom wants to merge 1 commit into
thrillfall:mainfrom
torvalstrom:fix/gis-capability-probe

Conversation

@torvalstrom

@torvalstrom torvalstrom commented Jul 26, 2026

Copy link
Copy Markdown

Problem

SimplePlaceResolver::detectGisType() infers GIS capability from the DB platform name: any PostgreSQL platform is assumed to have PostGIS. On a plain postgres server (no PostGIS extension - the common case for Nextcloud installs) every queryPoint() call then runs spatial SQL that can only fail:

  • one error_log line per photo per cron run - on a ~30k-photo library that was ~8,600 log lines/day, and ~47k/day on a 64k-photo library
  • one doomed query per point before the code falls back anyway

Fix

Probe the actual capability once, in the constructor path:

  • postgres: SELECT 1 FROM pg_extension WHERE extname = 'postgis'
  • mysql/mariadb: try a trivial ST_Contains() (built-in since MySQL 5.7 / MariaDB 10.2, but a stripped build also degrades cleanly this way)

If the probe fails, detectGisType() returns GIS_TYPE_NONE, so queryPoint() goes straight to fallbackByFileId() - which resolves places from the oc_memories_places table that Memories precomputes at index time. Place names still resolve fully; all three callers already pass fileid.

Verified

Running this exact change in production on Nextcloud 33 + plain postgres 16 since July: occ journeys:cluster over 64,341 photos → 1,105 clusters, 0 resolver errors (previously tens of thousands per day). Behavior on a server that does have PostGIS is unchanged (probe returns true, spatial path used as before).

🤖 Generated with Claude Code

…platform

A PostgreSQL platform does not imply PostGIS. On a plain postgres server
(the default for most Nextcloud installs) detectGisType() returned
GIS_TYPE_POSTGRES and every queryPoint() call ran PostGIS SQL that can
only fail: one logged error and one doomed query per photo per cron run
(~8.6k log lines/day on a ~30k-photo library) before falling back.

Probe capability instead of assuming it:
- postgres: check pg_extension for 'postgis'
- mysql/mariadb: try a trivial ST_Contains() (built-in since MySQL 5.7 /
  MariaDB 10.2, but a stripped build should also degrade cleanly)

When the probe fails, detectGisType() returns GIS_TYPE_NONE so
queryPoint() goes straight to fallbackByFileId(), which resolves places
from the oc_memories_places table Memories precomputes at index time -
place names still resolve fully, with zero errors.

Verified on Nextcloud 33 + plain postgres 16: occ journeys:cluster over
64k photos, 1105 clusters, 0 resolver errors (previously ~47k/day).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant