drolbr / Overpass-API

A database engine to query the OpenStreetMap data.
http://overpass-api.de
GNU Affero General Public License v3.0
692 stars 90 forks source link

Clone db: sometimes missing versions in attic? #661

Open mmd-osm opened 2 years ago

mmd-osm commented 2 years ago

I'm trying to track down an issue with missing / inconsistent attic versions, when running the following query against clone files in /var/www/clone/*

Query:

timeline(node,4379348552);
for (t["created"])
{
  retro (_.val)
  {
    node(4379348552);
    out meta;
  }
}

At the time of testing this, the following two directories were available:

Clone file 2022-04-11

~/osm-3s_v0.7.57.1 (master)$ bin/osm3s_query --db-dir=/var/www/clone/2022-04-11/ < q1
encoding remark: Please enter your query and terminate it with CTRL+D.
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Overpass API 0.7.57.1 74a55df1">
<note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note>
<meta osm_base=""/>

  <node id="4379348552" lat="8.5622709" lon="124.3512758" version="1" timestamp="2016-09-01T15:12:48Z" changeset="41851321" uid="4006023" user="kbferrer"/>
  <node id="4379348552" lat="8.5623289" lon="124.3513366" version="2" timestamp="2019-03-02T12:06:51Z" changeset="67711850" uid="9491539" user="zeyneppv"/>
  <node id="4379348552" lat="8.5622825" lon="124.3513409" version="3" timestamp="2022-04-10T04:30:52Z" changeset="119522695" uid="1041828" user="GOwin"/>

</osm>

Clone file 2022-04-10

~/osm-3s_v0.7.57.1 (master)$ bin/osm3s_query --db-dir=/var/www/clone/2022-04-10/ < q1
encoding remark: Please enter your query and terminate it with CTRL+D.
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Overpass API 0.7.57.1 74a55df1">
<note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note>
<meta osm_base=""/>

  <node id="4379348552" lat="8.5623289" lon="124.3513366" version="2" timestamp="2019-03-02T12:06:51Z" changeset="67711850" uid="9491539" user="zeyneppv"/>

</osm>

Issue: Version 1 for node 4379348552 is missing when reading 2022-04-10 clone files.

Version 3 was created at "2022-04-10T04:30:52Z", which happens to be in the 2022-04-10 clone file generation time window (this may be a coincidence).

From my analysis it seems that nodes_attic_undeleted might be lacking some entries, which in turn impacts filter_attic_elements in collect_members.h.

Clone files are generated while minutely diffs are being processed at the same time. Could this have some impact?

drolbr commented 2 years ago

Clone files are generated while minutely diffs are being processed at the same time. Could this have some impact?

It should not. The reads of the clone process (as any reads) are isolated from the writes of the minute updates. That is the whole point of the transactional design.

mmd-osm commented 2 years ago

I suspect that this is one of the bugs that is extremely difficult to reproduce and analyze.

Initially, I created a series of 24 hourly augmented diffs (time interval = 1 hour instead of 1 minute) and compared results on two different servers. For an entire day, there were less than 5 differences in total on nodes, ways and relations.

As I couldn't find a good explanation for the deviations, I started analyzing the nodes_attic_undeleted files with dump_file and compared the results from two clone databases on the dev instance.

I'm pretty sure this is a strange special case that occurs relatively rarely, otherwise there would be many more differences between the servers.