Uploaded image for project: 'Sentry'
  1. Sentry
  2. SENTRY-1881

PrivilegeOperatePersistence throws wrong type of exceptions

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.0, 2.0.0
    • Fix Version/s: 2.0.0
    • Component/s: Sentry
    • Labels:
      None

      Description

      The PrivilegeOperatePersistenc class uses wrong exceptions to throw, e.g.:

        private BitFieldAction getAction(String component, String name) {
          BitFieldActionFactory actionFactory = getActionFactory(component);
          BitFieldAction action = actionFactory.getActionByName(name);
          if (action == null) {
            throw new RuntimeException("can't get BitFieldAction for name:" + name);
          }
          return action;
        }
      

      Notice that it throws RuntimeException (which is a completely wrong exception to throw here). The problem is that these exceptions are retried at the TransactionManager level and never succeed so we are just waisting time. This particular bit is triggered by a test org.apache.sentry.provider.db.generic.service.thrift.TestAuditLogForSentryGenericService and we get the following exception which is retried many times:

      
      

      java.lang.RuntimeException: can't get BitFieldAction for name:invalidaction
      at org.apache.sentry.provider.db.generic.service.persistent.PrivilegeOperatePersistence.getAc
      tion(PrivilegeOperatePersistence.java:523)
      at org.apache.sentry.provider.db.generic.service.persistent.PrivilegeOperatePersistence.grant
      RolePartial(PrivilegeOperatePersistence.java:191)
      at org.apache.sentry.provider.db.generic.service.persistent.PrivilegeOperatePersistence.grant
      Privilege(PrivilegeOperatePersistence.java:181)
      at org.apache.sentry.provider.db.generic.service.persistent.DelegateSentryStore$1.execute(Del
      egateSentryStore.java:132)
      at org.apache.sentry.provider.db.service.persistent.TransactionManager.executeTransaction(Tra
      nsactionManager.java:123)
      at org.apache.sentry.provider.db.service.persistent.TransactionManager$1.call(TransactionMana
      ger.java:192)
      at org.apache.sentry.provider.db.service.persistent.TransactionManager$ExponentialBackoff.exe
      cute(TransactionManager.java:233)
      at org.apache.sentry.provider.db.service.persistent.TransactionManager.executeTransactionWith
      Retry(TransactionManager.java:188)
      at org.apache.sentry.provider.db.generic.service.persistent.DelegateSentryStore.alterRoleGran
      tPrivilege(DelegateSentryStore.java:119)
      at org.apache.sentry.provider.db.generic.service.thrift.SentryGenericPolicyProcessor$5.handle
      (SentryGenericPolicyProcessor.java:435)
      at org.apache.sentry.provider.db.generic.service.thrift.SentryGenericPolicyProcessor.requestH
      andle(SentryGenericPolicyProcessor.java:183)
      at org.apache.sentry.provider.db.generic.service.thrift.SentryGenericPolicyProcessor.alter_se
      ntry_role_grant_privilege(SentryGenericPolicyProcessor.java:431)
      at org.apache.sentry.provider.db.generic.service.thrift.SentryGenericPolicyService$Processor$
      alter_sentry_role_grant_privilege.getResult(SentryGenericPolicyService.java:877)
      at org.apache.sentry.provider.db.generic.service.thrift.SentryGenericPolicyService$Processor$
      alter_sentry_role_grant_privilege.getResult(SentryGenericPolicyService.java:862)
      at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
      at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
      at org.apache.sentry.provider.db.generic.service.thrift.SentryGenericPolicyProcessorWrapper.p
      rocess(SentryGenericPolicyProcessorWrapper.java:37)
      at org.apache.thrift.TMultiplexedProcessor.process(TMultiplexedProcessor.java:123)
      at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:286)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
      {code)

      Not only it is wrong, but also it sometimes triggers test failures because we may retry for longer then the test allocated time. We should use Sentry exceptions which are not retried by TransactionManager instead.

        Attachments

        1. SENTRY-1881.02.patch
          26 kB
          Sergio Peña
        2. SENTRY-1881.01.patch
          18 kB
          Alex Kolbasov

          Activity

            People

            • Assignee:
              spena Sergio Peña
              Reporter:
              akolb Alex Kolbasov
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified