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

[Int64] Incorrect results returned in case of scan for min int64 value

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.5.0
    • Fix Version/s: Mad-Hatter
    • Component/s: query
    • Environment:
      Build: 5.5.0-2556

      Node 1: kv, index, n1ql
    • Triage:
      Untriaged
    • Is this a Regression?:
      Unknown

      Description

      Steps:

      1. Install and configure cluster. Create bucket b1
      2. Have following documents:

      d1 - {"long_num":-9223372036854775808}
      d2 - {"long_num":-9223372036854770000}
      d3 - {"long_num":10}
      d4 - {"long_num":-2147483600}

      3. Create index i1

      create index i1 on b1(long_num)

       4. Run Following query:

      select long_num from b1 use index (i1) where long_num = -9223372036854775808

       Results obtained:

      {
      "results": []
      }

      Document d1 is also expected to be returned.  

      Explain Plan:

      {
      "plan": {
      "#operator": "Sequence",
      "~children": [
      {
      "#operator": "IndexScan3",
      "covers": [
      "cover ((`b1`.`long_num`))",
      "cover ((meta(`b1`).`id`))"
      ],
      "index": "i1",
      "index_id": "2c108fe5860faf10",
      "index_projection": {
      "entry_keys": [
      0
      ]
      },
      "keyspace": "b1",
      "namespace": "default",
      "spans": [
      {
      "exact": true,
      "range": [
      {
      "high": "(-9223372036854776000)",
      "inclusion": 3,
      "low": "(-9223372036854776000)"
      }
      ]
      }
      ],
      "using": "gsi"
      },
      {
      "#operator": "Parallel",
      "~child": {
      "#operator": "Sequence",
      "~children": [
      {
      "#operator": "Filter",
      "condition": "(cover ((`b1`.`long_num`)) = (-9223372036854776000))"
      },
      {
      "#operator": "InitialProject",
      "result_terms": [
      {
      "expr": "cover ((`b1`.`long_num`))"
      }
      ]
      },
      {
      "#operator": "FinalProject"
      }
      ]
      }
      }
      ]
      },
      "text": "select long_num from b1 use index (i1) where long_num = -9223372036854775808"

      5. If there is only Primary index and no secondary index on long_num, correct results are returned.

      [{
      "long_num": -9223372036854775808
      }
      ]

      Logs: https://s3.amazonaws.com/bugdb/jira/abc/collectinfo-2018-04-24T133516-ns_1%40127.0.0.1.zip

        Attachments

          Issue Links

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

            Activity

            Hide
            prathibha Prathibha Bisarahalli added a comment - - edited

            From explain plan, the span given to GSI is:

            "spans": [
                      {
                        "exact": true,
                        "range": [
                          {
                            "high": "(-9223372036854776000)",
                            "inclusion": 3,
                            "low": "(-9223372036854776000)"
                          }
                        ]
                      }
                    ],
            

            Since -9223372036854776000 does not exist in index, no results are returned. Also verified that datastore.Range2 low/high sent to GSI are:
            r.Low = -9223372036854776000 r.High = -9223372036854776000

            Assigning to query team for investigation. Prasanna Gholap - Can you please confirm the behavior when cbq shell is used?

            Show
            prathibha Prathibha Bisarahalli added a comment - - edited From explain plan, the span given to GSI is: "spans": [ { "exact": true, "range": [ { "high": "(-9223372036854776000)", "inclusion": 3, "low": "(-9223372036854776000)" } ] } ], Since -9223372036854776000 does not exist in index, no results are returned. Also verified that datastore.Range2 low/high sent to GSI are: r.Low = -9223372036854776000 r.High = -9223372036854776000 Assigning to query team for investigation. Prasanna Gholap - Can you please confirm the behavior when cbq shell is used?
            Hide
            Sitaram.Vemulapalli Sitaram Vemulapalli added a comment - - edited

            Json there is no integers everything is numbers and any value above 2**53 will loose precision and stored as float64.
            This is same as MB-24464. cc Keshav Murthy

            Show
            Sitaram.Vemulapalli Sitaram Vemulapalli added a comment - - edited Json there is no integers everything is numbers and any value above 2**53 will loose precision and stored as float64. This is same as MB-24464 . cc Keshav Murthy
            Hide
            prathibha Prathibha Bisarahalli added a comment - - edited

            Sitaram, pls clarify regarding MB-20164. Isn't int64 support in N1ql include query predicates as well ?

            Show
            prathibha Prathibha Bisarahalli added a comment - - edited Sitaram, pls clarify regarding MB-20164 . Isn't int64 support in N1ql include query predicates as well ?
            Hide
            prathibha Prathibha Bisarahalli added a comment - - edited

            Sitaram Vemulapalli - Please clarify if Int64 in query is supported for query predicates as well. -9223372036854775808 is MinInt64 that fits into Int64 precision, hence need to be supported in lookup queries.

            It works fine for MaxInt64 ie 9223372036854775807

            Show
            prathibha Prathibha Bisarahalli added a comment - - edited Sitaram Vemulapalli - Please clarify if Int64 in query is supported for query predicates as well. -9223372036854775808 is MinInt64 that fits into Int64 precision, hence need to be supported in lookup queries. It works fine for MaxInt64 ie 9223372036854775807

              People

              • Assignee:
                johan.larson Johan Larson
                Reporter:
                prasanna.gholap Prasanna Gholap
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes

                    PagerDuty

                    Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.