Skip to content

Imposm Stuck on Replication Due to Persistent “driver: bad connection” Errors #1086

Closed

Description

@Rub21

I’ve encountered a recurring issue with Imposm while it’s trying to apply minute replication updates. This time, the problem persists and prevents further tile updates.

In the past (when running in Kubernetes), this issue occurred occasionally and the pod restart mechanism usually fixed it. However, now that we’re running in Docker, the process is getting stuck indefinitely, unable to recover, and no tiles are being updated.

Here’s a snippet of the repeated error:

 delete element osm.Diff{Create:false, Modify:true, Delete:false, Node:(*osm.Node)(0xc002701380), Way:(*osm.Way)(nil), Rel:(*osm.Relation)(nil)}: deleting -2687310 from "admin_areas": SQL Error: driver: bad connection in query DELETE FROM "public"."osm_admin_areas" WHERE "osm_id" = $1 (-2687310)
[2025-06-25T06:34:16Z] 15:47:37 [info] Retrying in 5m0s
[2025-06-25T06:34:16Z] 15:47:37 [error] Importing #1779658: delete element osm.Diff{Create:false, Modify:true, Delete:false, Node:(*osm.Node)(0xc002701a70), Way:(*osm.Way)(nil), Rel:(*osm.Relation)(nil)}: deleting -2687310 from "admin_areas": SQL Error: driver: bad connection in query DELETE FROM "public"."osm_admin_areas" WHERE "osm_id" = $1 (-2687310)
[2025-06-25T06:34:16Z] 15:47:37 [info] Retrying in 5m0s
[2025-06-25T06:34:16Z] 15:47:37 [error] Importing #1779658: delete element osm.Diff{Create:false, Modify:true, Delete:false, Node:(*osm.Node)(0xc007492180), Way:(*osm.Way)(nil), Rel:(*osm.Relation)(nil)}: deleting -2687310 from "place_areas": SQL Error: driver: bad connection in query DELETE FROM "public"."osm_place_areas" WHERE "osm_id" = $1 (-2687310)
[2025-06-25T06:34:16Z] 15:47:37 [info] Retrying in 5m0s

I also noticed that the file being used to update the database is quite large compared to the others, which might be the reason for the issue.
https://s3.amazonaws.com/planet.openhistoricalmap.org/replication/minute/001/779/658.osc.gz

Image

I restarted the docker container manually and it start working again, also importing the #1779658 takes around 13 min to complete

Image

Activity

  1. Rub21 commented on Jun 26, 2025

    @Rub21
    MemberAuthor

    I worked on this issue to ensure that the container restarts automatically once the problem is detected. I still don’t know exactly why this issue is happening, but what I do know is that it gets resolved once the container is restarted. It might be a resource issue specific to the container, which Kubernetes handles by restarting it automatically—but that doesn’t happen in Docker environments.

    The script monitors the Imposm log, and if it detects an import error, it terminates both the expiration file upload and the Imposm update process. This causes the container to restart:

    https://github.com/OpenHistoricalMap/ohm-deploy/blob/fef5b2114cd6e6daf233bad75ea92256e50e5dc8/images/tiler-imposm/start.sh#L164-L200

  2. Rub21 commented on Jun 26, 2025

    @Rub21
    MemberAuthor

    Done, and currently working in production

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions