Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-26268

Concurrency issue when using multiple Collection Operators with same variable name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • None
    • 4.5.1
    • query
    • 4.5.1 CE
    • Untriaged
    • Centos 64-bit
    • Unknown

    Description

      In versions prior to 4.6.2 it is not possible to use arbitrary variable names with array indexes (see https://issues.couchbase.com/browse/MB-22646).

      As I'm using 4.5.1 CE I did use the exact same variable name as in the index definition. As I had to 2 where clauses using the same index, I've used the same variable name twice (even though in different parenthesis).

      select meta(`holder`).`id` 
      from `mybucket` as `holder` 
      where ClassName = 'ObjectName' AND 
      (ANY `refKey` IN `holder`.`refKeys` SATISFIES [`refKey`.`key`, `refKey`.`value`] = ['KEY1', 'VALUE1'] END) AND 
      (ANY `refKey` IN `holder`.`refKeys` SATISFIES [`refKey`.`key`, `refKey`.`value`] = ['KEY2', 'VALUE2'] END)
      

      when doing the results are random and different every time I do execute this query (sometimes all results are returned, sometimes just a few and in most cases none) which made me think it might be a concurrency issue.

      When using different variable names in the two collection operators everything is working as expected:

      select meta(`holder`).`id` 
      from `mybucket` as `holder` 
      where ClassName = 'ObjectName' AND 
      (ANY `refKey` IN `holder`.`refKeys` SATISFIES [`refKey`.`key`, `refKey`.`value`] = ['KEY1', 'VALUE1'] END) AND 
      (ANY `refKey1` IN `holder`.`refKeys` SATISFIES [`refKey1`.`key`, `refKey1`.`value`] = ['KEY2', 'VALUE2'] END)
      

      In versions prior to 4.6.2 this obviously results in the index not being used for the second collection operator, but at least there is a workaround, so it's not super urgent. But it's something which can easily happen and cause unexpected results.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              keshav Keshav Murthy
              prainer Peter Rainer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty