Skip to content

Tile rendering: Tables created by osm2pgsql are being deleted unexpectedly during tile rendering #450

@iaguerri

Description

@iaguerri

We are using the tile server from this repository (2.3.0) which internally relies on osm2pgsql 1.8. We've encountered a critical issue where the following tables are deleted intermittently:

  • planet_osm_line
  • planet_osm_point
  • planet_osm_polygon
  • planet_osm_roads

These tables are created by osm2pgsql during OSM import and are essential for tile rendering. Notably, only geometry-related tables are affected. Other tables such as simplified_water_polygons, icesheet_outlines, icesheet_polygons, and those used for update mechanisms remain unaffected.

Conditions Observed

  • Deletion seems to occur randomly, but mostly when querying the database, such as during tile rendering with render_list.
  • When the database is idle, data remains intact.
  • We do not have access to PostgreSQL logs to further trace the issue. In the localhost database, errors do not appear. We are talking about rendering in Production environment.
  • It has happened even in locally deployed databases, so it’s unlikely related to external configuration.

⚠ Additional Behavior

When trying to manually restore the deleted tables from backup, the import fails unless osm2pgsql triggers are disabled. The error shown is:

pg_restore: error: COPY failed for table "planet_osm_line": ERROR: function st_isvalid(public.geometry) does not exist
LINE 1: ST_IsValid(NEW.way)
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: ST_IsValid(NEW.way)
CONTEXT: PL/pgSQL function public.planet_osm_line_osm2pgsql_valid() line 3 at IF
COPY planet_osm_line, line 1: «564393473 psv \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N pedestrian \N \N \N \N \N \N \N \N \N Car...»
pg_restore: warning: errors ignored on restore: 1

Oddly, this trigger is present after the import, and when importing using osm2pgsql, no such error is thrown. This may or may not be related, but it's worth mentioning.

We have also been unable to locate Mapnik or render_list logs, so we cannot provide logs from the rendering side.


✅ Summary

  • Critical rendering tables are being deleted unexpectedly.
  • Appears linked to database access/rendering, not idle time.
  • Issue happens on local and server deployments.
  • Manual recovery is error-prone due to trigger-related errors.

Any insights or suggestions would be greatly appreciated.
Please let us know if there's any additional debugging information we could collect.

Thanks in advance!!!! 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions