You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Ildar Absalyamov (JIRA)" <ji...@apache.org> on 2015/09/24 01:25:04 UTC

[jira] [Comment Edited] (ASTERIXDB-1109) Index entries are not deleted on an open-type secondary index

    [ https://issues.apache.org/jira/browse/ASTERIXDB-1109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14905491#comment-14905491 ] 

Ildar Absalyamov edited comment on ASTERIXDB-1109 at 9/23/15 11:24 PM:
-----------------------------------------------------------------------

Young-Seok was right, 2ndary index delete operator never gets an input from the downstream. The reason is that early in the plan records, which come from primary, get recreated using closed constructor, thus loosing all open fields.
commit
{code:aql}
-- COMMIT  |PARTITIONED|
  project ([$$6])
  -- STREAM_PROJECT  |PARTITIONED|
    exchange 
    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
      delete from open_idx on test:Open from [%0->$$11]
      -- INDEX_INSERT_DELETE  |PARTITIONED|
        exchange 
        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
          project ([$$6, $$11])
          -- STREAM_PROJECT  |PARTITIONED|
            assign [$$11] <- [function-call: asterix:field-access-by-index, Args:[function-call: asterix:cast-record, Args:[%0->$$2], AInt32: {2}]]
            -- ASSIGN  |PARTITIONED|
              exchange 
              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                delete from test:Open from %0->$$2 partitioned by [%0->$$6]
                -- INSERT_DELETE  |PARTITIONED|
                  exchange 
                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                    materialize 
                    -- MATERIALIZE  |PARTITIONED|
                      exchange 
                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                        assign [$$6] <- [function-call: asterix:field-access-by-index, Args:[%0->$$2, AInt32: {0}]]
                        -- ASSIGN  |PARTITIONED|
                          project ([$$2])
                          -- STREAM_PROJECT  |PARTITIONED|
                            assign [$$2] <- [function-call: asterix:closed-record-constructor, Args:[AString: {id}, %0->$$7, AString: {sec}, function-call: asterix:field-access-by-index, Args:[%0->$$0, AInt32: {1}]]]
                            -- ASSIGN  |PARTITIONED|
                              exchange 
                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                data-scan []<-[$$7, $$0] <- test:Open
                                -- DATASOURCE_SCAN  |PARTITIONED|
                                  exchange 
                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                    empty-tuple-source
                                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
{code}
This record construction is introduced during initial AQL query plan translation and is carried through the whole optimization pipeline. 
I am not sure what is the reasoning behind that record construction. Why in the example above we cannot work with $$0 which comes out of datascan?


was (Author: iabsalyamov):
Young-Seok was right, 2ndary index delete operator never gets an input from the downstream. The reason is that early in the plan records, which come from primary, get recreated using closed constructor, thus loosing all open fields.
commit
-- COMMIT  |PARTITIONED|
  project ([$$6])
  -- STREAM_PROJECT  |PARTITIONED|
    exchange 
    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
      delete from open_idx on test:Open from [%0->$$11]
      -- INDEX_INSERT_DELETE  |PARTITIONED|
        exchange 
        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
          project ([$$6, $$11])
          -- STREAM_PROJECT  |PARTITIONED|
            assign [$$11] <- [function-call: asterix:field-access-by-index, Args:[function-call: asterix:cast-record, Args:[%0->$$2], AInt32: {2}]]
            -- ASSIGN  |PARTITIONED|
              exchange 
              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                delete from test:Open from %0->$$2 partitioned by [%0->$$6]
                -- INSERT_DELETE  |PARTITIONED|
                  exchange 
                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                    materialize 
                    -- MATERIALIZE  |PARTITIONED|
                      exchange 
                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                        assign [$$6] <- [function-call: asterix:field-access-by-index, Args:[%0->$$2, AInt32: {0}]]
                        -- ASSIGN  |PARTITIONED|
                          project ([$$2])
                          -- STREAM_PROJECT  |PARTITIONED|
                            assign [$$2] <- [function-call: asterix:closed-record-constructor, Args:[AString: {id}, %0->$$7, AString: {sec}, function-call: asterix:field-access-by-index, Args:[%0->$$0, AInt32: {1}]]]
                            -- ASSIGN  |PARTITIONED|
                              exchange 
                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                data-scan []<-[$$7, $$0] <- test:Open
                                -- DATASOURCE_SCAN  |PARTITIONED|
                                  exchange 
                                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                    empty-tuple-source
                                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|

This record construction is introduced during initial AQL query plan translation and is carried through the whole optimization pipeline. 
I am not sure what is the reasoning behind that record construction. Why in the example above we cannot work with $$0 which comes out of datascan?

> Index entries are not deleted on an open-type secondary index
> -------------------------------------------------------------
>
>                 Key: ASTERIXDB-1109
>                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-1109
>             Project: Apache AsterixDB
>          Issue Type: Bug
>            Reporter: Taewoo Kim
>            Assignee: Ildar Absalyamov
>            Priority: Critical
>
> Currently, index entries (SK, PK) are not deleted on an open-type secondary index. This issue was not surfaced due to the fact that every search after a secondary index search needs to go through the primary index lookup. Therefore, un-deleted entries were removed during this Pidx lookup.
> Now, we have an index-only plan that can skip the Pidx lookup after a Sidx search. Therefore, the query result is not correct anymore.
>   



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)