Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-1680

Java SDK3.0.5: -- comment statement from cluster.query() throws syntax error

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Incomplete
    • 3.0.5
    • None
    • N1QL
    • None
    • 1

    Description

      It has been observed that the cluster.query() from Java SDK 3.0.5 client is throwing the "message":"syntax error - at end of input" for a comment query. The expectation is that it should work as a no-op by ignoring this commented statement without no errors like the below in cbq.
      cbq> – fetches a row;
      cbq>

      See the below code snippet.

      query="-- fetches a row;"; 
      QueryResult result = cluster.query(query);
      

      Steps:
      1. git clone https://github.com/jdmuntacb/cbtest
      2. cd cbtest; mvn clean package
      3. Run the below java command and see the console snapshot:

       
      $ java -Durl=172.23.96.189 -Duser=Administrator -Dpassword=password -Drun=connectClusterOnly,query -Dquery="-- fetches a row;"  -jar target/cbtest-0.0.1-SNAPSHOT-jar-with-dependencies.jar
      Thu Jul 30 16:05:07 PDT 2020 *** Couchbase Tester ***
      Thu Jul 30 16:05:07 PDT 2020 -->Running connectClusterOnly
      Thu Jul 30 16:05:08 PDT 2020 Connecting to cluster
      Jul 30, 2020 4:05:08 PM com.couchbase.client.core.cnc.LoggingEventConsumer$JdkLogger info
      INFO: [com.couchbase.core][CoreCreatedEvent] {"clientVersion":null,"clientGitHash":null,"coreVersion":null,"coreGitHash":null,"userAgent":"couchbase-java/0.0.0 (Mac OS X 10.14.6 x86_64; Java HotSpot(TM) 64-Bit Server VM 11.0.4+10-LTS)","maxNumRequestsInRetry":32768,"ioEnvironment":{"nativeIoEnabled":true,"eventLoopThreadCount":6,"eventLoopGroups":["KQueueEventLoopGroup"]},"ioConfig":{"captureTraffic":[],"mutationTokensEnabled":true,"networkResolution":"auto","dnsSrvEnabled":false,"tcpKeepAlivesEnabled":true,"tcpKeepAliveTimeMs":60000,"configPollIntervalMs":2500,"kvCircuitBreakerConfig":"disabled","queryCircuitBreakerConfig":"disabled","viewCircuitBreakerConfig":"disabled","searchCircuitBreakerConfig":"disabled","analyticsCircuitBreakerConfig":"disabled","managerCircuitBreakerConfig":"disabled","numKvConnections":1,"maxHttpConnections":12,"idleHttpConnectionTimeoutMs":30000,"configIdleRedialTimeoutMs":300000},"compressionConfig":{"enabled":true,"minRatio":0.83,"minSize":32},"securityConfig":{"tlsEnabled":false,"nativeTlsEnabled":true,"hasTrustCertificates":false,"trustManagerFactory":"InsecureTrustManagerFactory"},"timeoutConfig":{"kvMs":2500,"kvDurableMs":10000,"managementMs":75000,"queryMs":75000,"viewMs":75000,"searchMs":75000,"analyticsMs":75000,"connectMs":10000,"disconnectMs":10000},"loggerConfig":{"customLogger":null,"fallbackToConsole":false,"disableSlf4j":false,"loggerName":"CouchbaseLogger","diagnosticContextEnabled":false},"orphanReporterConfig":{"emitIntervalMs":10000,"sampleSize":10,"queueLength":1024},"retryStrategy":"BestEffortRetryStrategy","requestTracer":"OwnedSupplier"} {"coreId":"0xb5f026d200000001","seedNodes":[{"address":"172.23.96.189"}]}
      Jul 30, 2020 4:05:08 PM com.couchbase.client.core.cnc.LoggingEventConsumer$JdkLogger info
      INFO: [com.couchbase.node][NodeConnectedEvent] Node connected {"coreId":"0xb5f026d200000001","managerPort":"8091","remote":"172.23.96.189"}
      Thu Jul 30 16:05:13 PDT 2020 Connected to cluster
      Thu Jul 30 16:05:13 PDT 2020 -->Running query
      Thu Jul 30 16:05:13 PDT 2020 Running Query: -- fetches a row;
      Thu Jul 30 16:05:15 PDT 2020 Failed: Parsing of the input failed
      com.couchbase.client.core.error.ParsingFailureException: Parsing of the input failed {"completed":true,"coreId":"0xb5f026d200000001","errors":[{"code":3000,"message":"syntax error - at end of input"}],"idempotent":false,"lastDispatchedFrom":"10.100.195.211:65129","lastDispatchedTo":"172.23.96.189:8093","requestId":2,"requestType":"QueryRequest","retried":12,"retryReasons":["ENDPOINT_TEMPORARILY_NOT_AVAILABLE","GLOBAL_CONFIG_LOAD_IN_PROGRESS"],"service":{"operationId":"b0615c34-993b-4f16-897f-bdd087917873","statement":"-- fetches a row;","type":"query"},"timeoutMs":75000,"timings":{"dispatchMicros":59960,"totalMicros":2211364}}
      	at com.couchbase.client.java.AsyncUtils.block(AsyncUtils.java:51)
      	at com.couchbase.client.java.Cluster.query(Cluster.java:393)
      	at com.couchbase.client.java.Cluster.query(Cluster.java:380)
      	at com.couchbase.cbtest.CouchbaseTester.runQuery(CouchbaseTester.java:865)
      	at com.couchbase.cbtest.CouchbaseTester.query(CouchbaseTester.java:937)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      	at com.couchbase.cbtest.CouchbaseTester.main(CouchbaseTester.java:101)
      	Suppressed: java.lang.Exception: The above exception was originally thrown by another thread at the following location.
      		at com.couchbase.client.core.io.netty.query.QueryChunkResponseParser.errorsToThrowable(QueryChunkResponseParser.java:130)
      		at java.base/java.util.Optional.map(Optional.java:265)
      		at com.couchbase.client.core.io.netty.query.QueryChunkResponseParser.error(QueryChunkResponseParser.java:117)
      		at com.couchbase.client.core.io.netty.chunk.ChunkedMessageHandler.lambda$maybeCompleteResponseWithFailure$1(ChunkedMessageHandler.java:259)
      		at java.base/java.util.Optional.orElseGet(Optional.java:369)
      		at com.couchbase.client.core.io.netty.chunk.ChunkedMessageHandler.maybeCompleteResponseWithFailure(ChunkedMessageHandler.java:258)
      		at com.couchbase.client.core.io.netty.chunk.ChunkedMessageHandler.channelRead(ChunkedMessageHandler.java:191)
      		at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
      		at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
      		at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
      		at com.couchbase.client.core.deps.io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
      		at com.couchbase.client.core.deps.io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
      		at com.couchbase.client.core.deps.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
      		at com.couchbase.client.core.deps.io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
      		at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
      		at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
      		at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
      		at com.couchbase.client.core.deps.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
      		at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
      		at com.couchbase.client.core.deps.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
      		at com.couchbase.client.core.deps.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
      		at com.couchbase.client.core.deps.io.netty.channel.kqueue.AbstractKQueueStreamChannel$KQueueStreamUnsafe.readReady(AbstractKQueueStreamChannel.java:544)
      		at com.couchbase.client.core.deps.io.netty.channel.kqueue.AbstractKQueueChannel$AbstractKQueueUnsafe.readReady(AbstractKQueueChannel.java:381)
      		at com.couchbase.client.core.deps.io.netty.channel.kqueue.KQueueEventLoop.processReady(KQueueEventLoop.java:211)
      		at com.couchbase.client.core.deps.io.netty.channel.kqueue.KQueueEventLoop.run(KQueueEventLoop.java:289)
      		at com.couchbase.client.core.deps.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
      		at com.couchbase.client.core.deps.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
      		at com.couchbase.client.core.deps.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
      		at java.base/java.lang.Thread.run(Thread.java:834)
      jmunta-mac:cbtest jagadeshmunta$ 
       
      Just to see run some other query to double check as working like below with -Dquery="SELECT 'hello' as greeting;" 
       
      jmunta-mac:cbtest jagadeshmunta$ java -Durl=172.23.96.189 -Duser=Administrator -Dpassword=password -Drun=connectClusterOnly,query -Dquery="SELECT 'hello' as greeting;"  -jar target/cbtest-0.0.1-SNAPSHOT-jar-with-dependencies.jar
      Thu Jul 30 16:07:11 PDT 2020 *** Couchbase Tester ***
      Thu Jul 30 16:07:11 PDT 2020 -->Running connectClusterOnly
      Thu Jul 30 16:07:12 PDT 2020 Connecting to cluster
      Jul 30, 2020 4:07:12 PM com.couchbase.client.core.cnc.LoggingEventConsumer$JdkLogger info
      INFO: [com.couchbase.core][CoreCreatedEvent] {"clientVersion":null,"clientGitHash":null,"coreVersion":null,"coreGitHash":null,"userAgent":"couchbase-java/0.0.0 (Mac OS X 10.14.6 x86_64; Java HotSpot(TM) 64-Bit Server VM 11.0.4+10-LTS)","maxNumRequestsInRetry":32768,"ioEnvironment":{"nativeIoEnabled":true,"eventLoopThreadCount":6,"eventLoopGroups":["KQueueEventLoopGroup"]},"ioConfig":{"captureTraffic":[],"mutationTokensEnabled":true,"networkResolution":"auto","dnsSrvEnabled":false,"tcpKeepAlivesEnabled":true,"tcpKeepAliveTimeMs":60000,"configPollIntervalMs":2500,"kvCircuitBreakerConfig":"disabled","queryCircuitBreakerConfig":"disabled","viewCircuitBreakerConfig":"disabled","searchCircuitBreakerConfig":"disabled","analyticsCircuitBreakerConfig":"disabled","managerCircuitBreakerConfig":"disabled","numKvConnections":1,"maxHttpConnections":12,"idleHttpConnectionTimeoutMs":30000,"configIdleRedialTimeoutMs":300000},"compressionConfig":{"enabled":true,"minRatio":0.83,"minSize":32},"securityConfig":{"tlsEnabled":false,"nativeTlsEnabled":true,"hasTrustCertificates":false,"trustManagerFactory":"InsecureTrustManagerFactory"},"timeoutConfig":{"kvMs":2500,"kvDurableMs":10000,"managementMs":75000,"queryMs":75000,"viewMs":75000,"searchMs":75000,"analyticsMs":75000,"connectMs":10000,"disconnectMs":10000},"loggerConfig":{"customLogger":null,"fallbackToConsole":false,"disableSlf4j":false,"loggerName":"CouchbaseLogger","diagnosticContextEnabled":false},"orphanReporterConfig":{"emitIntervalMs":10000,"sampleSize":10,"queueLength":1024},"retryStrategy":"BestEffortRetryStrategy","requestTracer":"OwnedSupplier"} {"coreId":"0xb73f96b700000001","seedNodes":[{"address":"172.23.96.189"}]}
      Jul 30, 2020 4:07:12 PM com.couchbase.client.core.cnc.LoggingEventConsumer$JdkLogger info
      INFO: [com.couchbase.node][NodeConnectedEvent] Node connected {"coreId":"0xb73f96b700000001","managerPort":"8091","remote":"172.23.96.189"}
      Thu Jul 30 16:07:17 PDT 2020 Connected to cluster
      Thu Jul 30 16:07:17 PDT 2020 -->Running query
      Thu Jul 30 16:07:17 PDT 2020 Running Query: SELECT 'hello' as greeting;
      Thu Jul 30 16:07:19 PDT 2020 Found row: {"greeting":"hello"}
      

      Attachments

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

        Activity

          The clients are not parsing the input n1ql string, and this error is coming from the query engine. If you want to see it returning no data this change needs to be made in the query engine.

          For what it's worth, if you run "-- fetches a row;" in the query UI you also get:

          [
            {
              "code": 3000,
              "msg": "syntax error - at end of input",
              "query": "-- fetches a row;"
            }
          ]
          

          daschl Michael Nitschinger added a comment - The clients are not parsing the input n1ql string, and this error is coming from the query engine. If you want to see it returning no data this change needs to be made in the query engine. For what it's worth, if you run "-- fetches a row;" in the query UI you also get: [ { "code": 3000, "msg": "syntax error - at end of input", "query": "-- fetches a row;" } ]

          People

            daschl Michael Nitschinger
            jagadesh.munta@couchbase.com Jagadesh Munta
            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