Uploaded image for project: 'Apache AsterixDB'
  1. Apache AsterixDB
  2. ASTERIXDB-2176

Deletion doesn't work on the RTree index.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      This is a simplified version of "upsert/primary-secondary-tree" AQL test case.

      spatialData.json file

      { "id": 12, "point": point("6.0,3.0") }

      moreSpatialData.json file

      {"id": 12, "point": point("4.1,7.0")}

      DDL:

      drop dataverse test if exists;
      create dataverse test;
      use dataverse test;
      
      create type MyRecord as closed {
        id: int64,
        point: point
      }
      
      create dataset UpsertTo(MyRecord)
       primary key id;
      
      create dataset UpsertFrom(MyRecord)
       primary key id;
      
      create index rtree_index_point on UpsertTo(point) type rtree;
      

      DML

      load dataset UpsertTo
      using localfs
      (("path"="asterix_nc1://data/spatial/spatialData.json"),("format"="adm"));
      
      load dataset UpsertFrom
      using localfs
      (("path"="asterix_nc1://data/spatial/moreSpatialData.json"),("format"="adm"));
      
      upsert into dataset UpsertTo(
      for $x in dataset UpsertFrom
      return $x
      );
      
      for $o in dataset('UpsertTo')
      where spatial-intersect($o.point, create-polygon([4.0,1.0,4.0,4.0,12.0,4.0,12.0,1.0]))
      order by $o.id
      return $o;
      

      This DML returns the new record correctly. But, the issue is that the indexed value in RTree has not been updated.

      When searching the rtree_index_point index, the searcher sees the previous value - point("6.0,3.0"), not the new value - point("4.1,7.0"). So, this record will be fetched from the primary index. However, the primary index search returns the updated value and the select() verifies the value. It returns true by coincidence because the new value satisfies the spatial-intersect() condition.

      The secondary index search should see the updated value, not the previous value. And this is an issue for the index-only plan case since it only uses the value from a secondary index.

        Attachments

          Activity

            People

            • Assignee:
              luochen01 Chen Luo
              Reporter:
              wangsaeu Taewoo Kim
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: