Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-20614

REST scan API with incorrect filter text file throws HTTP 503 Service Unavailable error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 3.0.0-alpha-1, 2.2.0, 2.1.1, 2.0.2
    • REST
    • None
    • Reviewed

    Description

      Problem:

      HBase rest server returns a 503 Server Unavailable when generating a scanner object fails using the hbase rest server interface.

      The error code returned by hbase rest server is incorrect and may mislead the user.

      The exception caused by the wrong filter should ideally give Response.Status.BAD_REQUEST but it gives Response.Status.SERVICE_UNAVAILABLE which may mislead the user.

      Root cause:

      The ScannerModel.buildFilter throws JsonParseException/JsonMappingException depending on the below described scenarios which is not handled by the ScannerResource.update() method and thus returns Response.Status.SERVICE_UNAVAILABLE as response

        public static Filter buildFilter(String s) throws Exception {
          FilterModel model = getJasonProvider().locateMapper(FilterModel.class,
              MediaType.APPLICATION_JSON_TYPE).readValue(s, FilterModel.class);
          return model.build();
        }
      

       

      Steps to reproduce :

      (Scenario 1) JsonMappingException

      • Run the following having a wrong tag type1:
        curl -vi -X PUT -H "Content-Type:text/xml" -d '<Scanner batch="100"><filter>{"type1": "PrefixFilter","value": "cg=="}</filter></Scanner>' "http://localhost:11120/test/scanner/"
        
      • Response
        * Trying 127.0.0.1...
        * Connected to localhost (127.0.0.1) port 11120 (#0)
        > POST /test/scanner/ HTTP/1.1
        > Host: localhost:11120
        > User-Agent: curl/7.47.0
        > Accept: */*
        > Content-Type: text/xml
        > Content-Length: 89
        > 
        * upload completely sent off: 89 out of 89 bytes
        < HTTP/1.1 503 Service Unavailable
        < Content-Type: text/plain
        < Content-Length: 13
        < 
        Unavailable
        * Connection #0 to host localhost left intact
        
      • Exception Trace
      2018-05-25 14:06:49,781 INFO  [main] server.Server: Started @2337ms
      2018-05-25 14:07:18,908 ERROR [qtp1810899357-32] rest.ScannerResource: Exception occured while processing http://localhost:11120/test/scanner/ : 
      com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "type1" (class org.apache.hadoop.hbase.rest.model.ScannerModel$FilterModel), not marked as ignorable (20 known properties: "prefixes", "op", "family", "dropDependentColumn", "minColumn", "ifMissing", "qualifier", "value", "maxColumnInclusive", "offset", "chance", "comparator", "type", "filters", "timestamps", "minColumnInclusive", "latestVersion", "ranges", "limit", "maxColumn"])
       at [Source: (String)"{"type1": "PrefixFilter","value": "cg=="}"; line: 1, column: 12] (through reference chain: org.apache.hadoop.hbase.rest.model.ScannerModel$FilterModel["type1"])
      	at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:60)
      	at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:822)
      	at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1152)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1567)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1545)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
      	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001)
      	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2992)
      	at org.apache.hadoop.hbase.rest.model.ScannerModel.buildFilter(ScannerModel.java:491)
      	at org.apache.hadoop.hbase.rest.ResultGenerator.buildFilter(ResultGenerator.java:44)
      	at org.apache.hadoop.hbase.rest.ScannerResultGenerator.buildFilterFromModel(ScannerResultGenerator.java:54)
      	at org.apache.hadoop.hbase.rest.ScannerResource.update(ScannerResource.java:98)
      	at org.apache.hadoop.hbase.rest.ScannerResource.post(ScannerResource.java:151)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
      	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
      	at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
      	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
      	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
      	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
      	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
      	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
      	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
      	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
      	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
      	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
      	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
      	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1772)
      	at org.apache.hadoop.hbase.rest.filter.GzipFilter.doFilter(GzipFilter.java:77)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
      	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
      	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
      	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)
      	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
      	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
      	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
      	at org.eclipse.jetty.server.Server.handle(Server.java:534)
      	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
      	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
      	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)
      	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)
      	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
      	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
      	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
      	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
      	at java.lang.Thread.run(Thread.java:748)
      

       

      (Scenario 2) JsonParseException

      • Run the following having an extra comma symbol:
        curl -vi -X PUT -H "Content-Type:text/xml" -d '<Scanner batch="100"><filter>{"type": "PrefixFilter",,"value": "cg=="}</filter></Scanner>' "http://localhost:11120/test/scanner/"
        
      • Response
        *   Trying 127.0.0.1...
        * Connected to localhost (127.0.0.1) port 11120 (#0)
        > PUT /test/scanner/ HTTP/1.1
        > Host: localhost:11120
        > User-Agent: curl/7.47.0
        > Accept: */*
        > Content-Type:text/xml
        > Content-Length: 89
        > 
        * upload completely sent off: 89 out of 89 bytes
        < HTTP/1.1 503 Service Unavailable
        HTTP/1.1 503 Service Unavailable
        < Content-Type: text/plain
        Content-Type: text/plain
        < Content-Length: 13
        Content-Length: 13
        
        < 
        Unavailable
        * Connection #0 to host localhost left intact
        
      • Exception trace
      2018-05-30 16:24:34,056 ERROR [qtp1810899357-27] rest.ScannerResource: Exception occured while processing http://localhost:11120/test/scanner/ : 
      com.fasterxml.jackson.core.JsonParseException: Unexpected character (',' (code 44)): was expecting double-quote to start field name
       at [Source: (String)"{"type": "PrefixFilter",,"value": "cg=="}"; line: 1, column: 26]
      	at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1798)
      	at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:663)
      	at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:561)
      	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddName(ReaderBasedJsonParser.java:1757)
      	at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextFieldName(ReaderBasedJsonParser.java:907)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:294)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
      	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001)
      	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2992)
      	at org.apache.hadoop.hbase.rest.model.ScannerModel.buildFilter(ScannerModel.java:491)
      	at org.apache.hadoop.hbase.rest.ResultGenerator.buildFilter(ResultGenerator.java:44)
      	at org.apache.hadoop.hbase.rest.ScannerResultGenerator.buildFilterFromModel(ScannerResultGenerator.java:54)
      	at org.apache.hadoop.hbase.rest.ScannerResource.update(ScannerResource.java:98)
      	at org.apache.hadoop.hbase.rest.ScannerResource.put(ScannerResource.java:140)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
      	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
      	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
      	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
      	at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
      	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
      	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      	at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
      	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
      	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
      	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
      	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
      	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
      	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
      	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
      	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
      	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1772)
      	at org.apache.hadoop.hbase.rest.filter.GzipFilter.doFilter(GzipFilter.java:77)
      	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
      	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
      	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
      	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
      	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)
      	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
      	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
      	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
      	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
      	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
      	at org.eclipse.jetty.server.Server.handle(Server.java:534)
      	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
      	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
      	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)
      	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)
      	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
      	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
      	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
      	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
      	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
      	at java.lang.Thread.run(Thread.java:748)
      

      Attachments

        Activity

          People

            nihaljain.cs Nihal Jain
            nihaljain.cs Nihal Jain
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: