Skip to content

Keep new attic skeletons when importing into an empty database with attic - #51

Open
cldellow wants to merge 1 commit into
masterfrom
history-import-attic-skeletons
Open

cldellow wants to merge 1 commit into
masterfrom
history-import-attic-skeletons

Conversation

@cldellow

Copy link
Copy Markdown
Owner

Fixes #34.

Collected with the other import changes on better-imports, which is kept apart from all-changes.

Change

Node_Updater and Way_Updater initialise partial_possible to false when keeping attic data, and the constructor body then overwrites it with "the database files don't exist yet". So a fresh update_database --keep-attic import runs in partial mode. After each node or way update, partial mode clears new_skeletons, attic_skeletons and new_attic_skeletons.

The way updater needs the new attic node skeletons to compute the geometry and index of older way versions, and the relation updater needs the new attic way skeletons likewise. With them cleared, a way version that is older than the latest move of one of its nodes gets an empty geometry and the placeholder index, so [date:] queries by bounding box don't find it.

The change keeps the initialiser's intent: partial updates only without attic data. Two constructors, two lines each.

Impact

  • Benchmark queries and the prompting query: none. Only update_database, update_from_dir and migrate_database link the changed files; osm3s_query is built from the same code as on upstream/master. Not re-timed.

  • Import: a Geofabrik full-history extract of Prince Edward Island (licensed, not shareable; 3.1 M node, 291 k way and 28 k relation versions), imported with osmium cat x.osh.pbf -f osh -o - | update_database --db-dir=db/ --keep-attic on a 4-core, 15 GB cloud container (page cache not dropped between runs):

    upstream/master this PR
    Wall time 2:39 3:01
    CPU (user + sys) 156 s 178 s
    Peak RSS 1.46 GB 1.92 GB
    Database size 5.4 GB 5.5 GB

    Single runs each; the run for this PR overlapped with other jobs on the machine, so its time is indicative only. The extra memory is the attic skeletons that are no longer cleared; they are bounded by one batch, as in diff updates.

Testing

For each date, all objects in the world box at that date, compared with osmium time-filter <file> <date>:

[date:"2018-01-01T00:00:00Z"][maxsize:4000000000][timeout:3600];
(node(-90,-180,90,180);way(-90,-180,90,180);rel(-90,-180,90,180););
out meta;
Date Ways, osmium Missing on upstream/master Missing with this PR
2010-01-01 2,094 842 not measured with this PR alone
2018-01-01 73,186 7,469 0
2026-11-16 172,463 0 0

Missing relations at 2018 drop from 188 to 68; all 68 have no node or way member present at that date in the extract, so Overpass can't locate them by design (it locates relations by node and way members only).

Not fixed here, because they need the other history-import changes: deleted versions (#45), ways using deleted nodes (#46), imports in several batches (#47), flushes inside an element's versions (#48).

Limitations

  • Fresh --keep-attic imports now update the database in place after each flush instead of writing partial files and merging them. For PEI that cost about 10% more time in one run; not measured on a large file.

Generated by Claude Code

…ttic

Node_Updater and Way_Updater initialise partial_possible to false when keeping
attic data, but the constructor body then overwrites it with "the database
files don't exist yet". So a fresh `update_database --keep-attic` import runs in
partial mode, and partial mode clears new_skeletons, attic_skeletons and
new_attic_skeletons after each node or way update.

The way updater needs the new attic node skeletons to compute the geometry and
index of older way versions, and the relation updater needs the new attic way
skeletons likewise. Without them, a way version that is older than the latest
move of one of its nodes gets an empty geometry and the invalid index, so
[date:] queries by bounding box don't find it.

Keep the initialiser's intent: partial updates only without attic data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01736kJV9ygtU1g57EBR2Ufo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Fixes wrong results (in addition to the kind label) import-fix Fixes to update_database / history imports; collected on better-imports, not all-changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Direct full-history import builds wrong geometry for old way versions

2 participants