Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-5594

CassandraAuthorizer.authorize(AuthenticatedUser, IResource) should use prepared statement

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: 1.2.6
    • Component/s: None
    • Labels:

      Description

      The query in the authorize method will be extensively, providing you have configured Cassandra to use CassandraAuthorizer. Given the frequency of this query against the permissions CF, a prepared statement should be used here. There is a non-trivial amount of overhead involved with parsing a statement; so, this query would greatly benefit given how much it is run.

      While I was doing some testing recently, I eventually hit some timeout exceptions, but the timeouts were from the query in the authorize method. Here is a recent stack trace from one such exception,

      ERROR [Native-Transport-Requests:11] 2013-05-20 16:16:16,702 ErrorMessage.java (line 210) Unexpected exception during request
      com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: org.apache.cassandra.exceptions.ReadTimeoutException: Operation timed out - received only 0 responses.
      at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2258)
      at com.google.common.cache.LocalCache.get(LocalCache.java:3990)
      at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3994)
      at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4878)
      at org.apache.cassandra.service.ClientState.authorize(ClientState.java:290)
      at org.apache.cassandra.service.ClientState.ensureHasPermission(ClientState.java:170)
      at org.apache.cassandra.service.ClientState.hasAccess(ClientState.java:163)
      at org.apache.cassandra.service.ClientState.hasColumnFamilyAccess(ClientState.java:147)
      at org.apache.cassandra.cql3.statements.ModificationStatement.checkAccess(ModificationStatement.java:69)
      at org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:131)
      at org.apache.cassandra.cql3.QueryProcessor.processPrepared(QueryProcessor.java:257)
      at org.apache.cassandra.transport.messages.ExecuteMessage.execute(ExecuteMessage.java:121)
      at org.apache.cassandra.transport.Message$Dispatcher.messageReceived(Message.java:287)
      at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
      at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:565)
      at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:793)
      at org.jboss.netty.handler.execution.ChannelUpstreamEventRunnable.doRun(ChannelUpstreamEventRunnable.java:45)
      at org.jboss.netty.handler.execution.ChannelEventRunnable.run(ChannelEventRunnable.java:69)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:722)
      Caused by: java.lang.RuntimeException: org.apache.cassandra.exceptions.ReadTimeoutException: Operation timed out - received only 0 responses.
      at org.apache.cassandra.auth.Auth.isSuperuser(Auth.java:95)
      at org.apache.cassandra.auth.AuthenticatedUser.isSuper(AuthenticatedUser.java:50)
      at org.apache.cassandra.auth.CassandraAuthorizer.authorize(CassandraAuthorizer.java:61)
      at org.apache.cassandra.service.ClientState$1.load(ClientState.java:276)
      at org.apache.cassandra.service.ClientState$1.load(ClientState.java:273)
      at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3589)
      at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2374)
      at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2337)
      at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2252)
      ... 20 more
      Caused by: org.apache.cassandra.exceptions.ReadTimeoutException: Operation timed out - received only 0 responses.
      at org.apache.cassandra.service.ReadCallback.get(ReadCallback.java:99)
      at org.apache.cassandra.service.StorageProxy.fetchRows(StorageProxy.java:941)
      at org.apache.cassandra.service.StorageProxy.read(StorageProxy.java:829)
      at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:124)
      at org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:56)
      at org.apache.cassandra.cql3.QueryProcessor.processStatement(QueryProcessor.java:132)
      at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:143)
      at org.apache.cassandra.cql3.QueryProcessor.process(QueryProcessor.java:151)
      at org.apache.cassandra.auth.Auth.isSuperuser(Auth.java:90)
      ... 28 more

        Attachments

          Activity

            People

            • Assignee:
              aleksey Aleksey Yeschenko
              Reporter:
              jsanda John Sanda
              Authors:
              Aleksey Yeschenko
              Reviewers:
              Jonathan Ellis
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: