Skip to content

Tile update delay — Cache Purging and Materialized View refresh timing #1080

Closed

Description

@Rub21

Context

From: https://developmentseed.slack.com/archives/CACTQ7MU4/p1749859483693599

We observed a delay in tile updates for changeset 177843. The changes were visible in some zoom levels but missing or partially rendered in others, even after 2+ hours.

Initial assumption was that the vector tile pipeline was slow or stalled. However, investigation shows a more nuanced issue related to materialized views refresh.

What Happened

  • Step 1. The changeset entered the OHM database and proceeded through minute replication as expected.
  • Step 2. It was then picked up by Imposm and written into the vtiles database. and generated expired tiles files
  • Step 3. Tiler cache takes that expired tiles files and cleaning happens for the edited area.
  • Step 4. However, tiles were requested before the materialized views were fully refreshed. (materialized views are created from Imposm tables), This issue can often occur when a user makes edits and expects to see their changes reflected immediately.
  • Step 5. Tegola generated tiles using the outdated views, caching results that excluded the new data.
  • Step 6. As a result, cached tiles served outdated content despite the database being updated.
  • Step 7. Multilingual view updates may further increase the frequency of this type of issue as we expand.

Proposed Next Steps

Implement a second round of cache purge after materialized views are updated (not just after raw imports) or delay a bit more the cache cleaning.

Your feedback or ideas to improve this cache cleaning would be appreciated :).

cc. @1ec5 @batpad

Activity

  1. Rub21 commented on Jun 26, 2025

    @Rub21
    MemberAuthor

    I have implemented a mechanism that cleans the affected area twice. The first cleanup happens immediately when the Imposm expiration files are generated and uploaded in s3. The second cleanup occurs one hour later. This one-hour delay ensures that all materialized views have been fully updated.

    The key is that once we receive the SQS message from the expiration files, the script starts cleaning up the tiles. at same time it generates a delayed SQS message, which will be processed again after one hour by the same script.
    • Generating the delayed SQS message:
    https://github.com/OpenHistoricalMap/ohm-deploy/blob/fef5b2114cd6e6daf233bad75ea92256e50e5dc8/images/tiler-cache/sqs_processor.py#L125-L131
    • After one hour, the same area is cleaned again using that delayed message:
    https://github.com/OpenHistoricalMap/ohm-deploy/blob/fef5b2114cd6e6daf233bad75ea92256e50e5dc8/images/tiler-cache/sqs_processor.py#L87-L94

    With this mechanism, we ensure that the vector tiles will show refreshed data immediately—or at most within one hour.

  2. Rub21 commented on Jun 26, 2025

    @Rub21
    MemberAuthor

    Done

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

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions