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

Application hangs when N1QL Parameterized Prepared Statement is executed with adhoc=false

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.5.1, 4.6.4, 5.0.1, 5.5.0
    • 6.5.0
    • query
    • Triaged
    • Unknown

    Description

      Issue

      The application hangs when executing a N1QL Parameterized prepared query when adhoc is set to false.

      Reproduction

      This is the prepared statement executed through the Query Workbench:

      prepare ps_test as select * from `travel-sample` where id = $id

      This is the code (snippet)

      JsonObject placeholderValues = JsonObject.create().put("id", 10);
      N1qlQuery hangQueryParameterized = N1qlQuery.parameterized("execute ps_test", 
      placeholderValues,N1qlParams.build().consistency(ScanConsistency.REQUEST_PLUS).adhoc(false));
      N1qlQueryResult queryResultParameterized = bucket.query(hangQueryParameterized);
      for (N1qlQueryRow row : queryResultParameterized) {
       System.out.println(row);
      }

      ... hangs

      Right usage

      Setting adhoc(true) in code snippet is the right usage. Here is the completed_requests:

       

      {
       "completed_requests": {
       "elapsedTime": "7.027909111s",
       "errorCount": 0,
       "node": "10.111.170.101:8091",
       "phaseCounts": {
       "fetch": 31591,
       "primaryScan": 31591
       },
       "phaseOperators": {
       "authorize": 1,
       "fetch": 1,
       "primaryScan": 1
       },
       "preparedName": "ps_test",
       "preparedText": "prepare ps_test as select * from `travel-sample` where id = $id",
       "remoteAddr": "10.111.170.1:58164",
       "requestId": "da5f63fe-5c61-44c6-ae0b-0a9157988a7d",
       "requestTime": "2018-02-14 00:02:29.477282904 +0000 UTC",
       "resultCount": 1,
       "resultSize": 138,
       "scanConsistency": "scan_plus",
       "serviceTime": "7.027839477s",
       "state": "completed",
       "statement": "execute ps_test",
       "userAgent": "couchbase-java-client/2.5.3 (git: 2.5.3, core: 1.5.3) (Mac OS X/10.13.3 x86_64; Java HotSpot(TM) 64-Bit Server VM 1.8.0_144-b01)",
       "users": "test"
       }
       },
      

       

       

      Attachments

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

        Activity

          marco.greco Marco Greco added a comment -

          Just to clarify - the fix here is going to be to disallow nested PREPARE PREPARE and PREPARE EXECUTE (which are generated with adhoc=false) and return errors instead.
          The client will still have to set adhoc to true to prepare and execute named statements.

          marco.greco Marco Greco added a comment - Just to clarify - the fix here is going to be to disallow nested PREPARE PREPARE and PREPARE EXECUTE (which are generated with adhoc=false) and return errors instead. The client will still have to set adhoc to true to prepare and execute named statements.
          marco.greco Marco Greco added a comment -

          Raju Suravarjjala This is too complex a fix for Vulcan, and if the customer prepares named statements correctly (adhoc=true), they will avoid the issue anyway.
          The fix is to disallow (as in return an error) named prepared statements with adhoc=false, so I think we can just move this to mad-hatter.

          marco.greco Marco Greco added a comment - Raju Suravarjjala This is too complex a fix for Vulcan, and if the customer prepares named statements correctly (adhoc=true), they will avoid the issue anyway. The fix is to disallow (as in return an error) named prepared statements with adhoc=false, so I think we can just move this to mad-hatter.

          Build couchbase-server-6.5.0-1006 contains query commit d56ccd8 with commit message:
          MB-28424 cleanup PREPARE / EXECUTE / EXPLAIN grammar rules

          build-team Couchbase Build Team added a comment - Build couchbase-server-6.5.0-1006 contains query commit d56ccd8 with commit message: MB-28424 cleanup PREPARE / EXECUTE / EXPLAIN grammar rules

          Verified in 6.5.0-4432

          evgeny.makarenko Evgeny Makarenko (Inactive) added a comment - Verified in 6.5.0-4432

          People

            korrigan.clark Korrigan Clark
            krishna.doddi Krishna Doddi
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty