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

Setting GrantOption to UNSET upsets Sentry

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.0, 2.0.0
    • Fix Version/s: 1.8.0, 2.0.0
    • Component/s: Sentry
    • Labels:

      Description

      If we send a Thrift request to sentry (using regular api) with GrantOption set to UNSET (-1) we get the following error:

      TransactionManager.executeTransactionWithRetry(TransactionManager.java:102)] The transaction has reac
      hed max retry number, will not retry again.
      javax.jdo.JDODataStoreException: Insert of object "org.apache.sentry.provider.db.service.model.MSentryPrivilege@6bbfd4c9" using statement "INSERT INTO `SENTRY_DB_PRIVILEGE` (`DB_PRIVILEGE_ID`,`SERVER_NAME`,`WITH_GRANT_OPTION`,`CREATE_TIME`,`TABLE_NAME`,`URI`,`ACTION`,`COLUMN_NAME`,`DB_NAME`,`PRIVILEGE_SCOPE`) VALUES (?,?,?,?,?,?,?,?,?,?)" failed : Column 'WITH_GRANT_OPTION' cannot be null
              at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:451)
              at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:732)
              at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:752)
              at org.apache.sentry.provider.db.service.persistent.SentryStore.alterSentryRoleGrantPrivilegeCore(SentryStore.java:438)
              at org.apache.sentry.provider.db.service.persistent.SentryStore.access$500(SentryStore.java:95)
              at org.apache.sentry.provider.db.service.persistent.SentryStore$8.execute(SentryStore.java:374)
              at org.apache.sentry.provider.db.service.persistent.TransactionManager.executeTransaction(TransactionManager.java:72)
              at org.apache.sentry.provider.db.service.persistent.TransactionManager.executeTransactionWithRetry(TransactionManager.java:93)
              at org.apache.sentry.provider.db.service.persistent.SentryStore.alterSentryRoleGrantPrivileges(SentryStore.java:367)
              at org.apache.sentry.provider.db.service.thrift.SentryPolicyStoreProcessor.alter_sentry_role_grant_privilege(SentryPolicyStoreProcessor.java:280)
              at org.apache.sentry.provider.db.service.thrift.SentryPolicyService$Processor$alter_sentry_role_grant_privilege.getResult(SentryPolicyService.java:1237)
              at org.apache.sentry.provider.db.service.thrift.SentryPolicyService$Processor$alter_sentry_role_grant_privilege.getResult(SentryPolicyService.java:1222)
              at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
              at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
              at org.apache.sentry.provider.db.service.thrift.SentryProcessorWrapper.process(SentryProcessorWrapper.java:35)
              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)
      NestedThrowablesStackTrace:
      com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'WITH_GRANT_OPTION' cannot be null
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
              at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
              at com.mysql.jdbc.Util.getInstance(Util.java:387)
              at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:934)
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3966)
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3902)
              at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2526)
              at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2673)
              at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2549)
              at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
              at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2073)
              at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2009)
              at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5098)
              at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1994)
              at com.jolbox.bonecp.PreparedStatementHandle.executeUpdate(PreparedStatementHandle.java:205)
              at org.datanucleus.store.rdbms.ParamLoggingPreparedStatement.executeUpdate(ParamLoggingPreparedStatement.java:399)
              at org.datanucleus.store.rdbms.SQLController.executeStatementUpdate(SQLController.java:439)
              at org.datanucleus.store.rdbms.request.InsertRequest.execute(InsertRequest.java:410)
              at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertTable(RDBMSPersistenceHandler.java:167)
              at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertObject(RDBMSPersistenceHandler.java:143)
              at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:3784)
              at org.datanucleus.state.JDOStateManager.makePersistent(JDOStateManager.java:3760)
              at org.datanucleus.ExecutionContextImpl.persistObjectInternal(ExecutionContextImpl.java:2219)
              at org.datanucleus.ExecutionContextImpl.persistObjectWork(ExecutionContextImpl.java:2065)
              at org.datanucleus.ExecutionContextImpl.persistObject(ExecutionContextImpl.java:1913)
              at org.datanucleus.ExecutionContextThreadedImpl.persistObject(ExecutionContextThreadedImpl.java:217)
              at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:727)
              at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:752)
              at org.apache.sentry.provider.db.service.persistent.SentryStore.alterSentryRoleGrantPrivilegeCore(SentryStore.java:438)
              at org.apache.sentry.provider.db.service.persistent.SentryStore.access$500(SentryStore.java:95)
              at org.apache.sentry.provider.db.service.persistent.SentryStore$8.execute(SentryStore.java:374)
              at org.apache.sentry.provider.db.service.persistent.TransactionManager.executeTransaction(TransactionManager.java:72)
              at org.apache.sentry.provider.db.service.persistent.TransactionManager.executeTransactionWithRetry(TransactionManager.java:93)
              at org.apache.sentry.provider.db.service.persistent.SentryStore.alterSentryRoleGrantPrivileges(SentryStore.java:367)
              at org.apache.sentry.provider.db.service.thrift.SentryPolicyStoreProcessor.alter_sentry_role_grant_privilege(SentryPolicyStoreProcessor.java:280)
              at org.apache.sentry.provider.db.service.thrift.SentryPolicyService$Processor$alter_sentry_role_grant_privilege.getResult(SentryPolicyService.java:1237)
              at org.apache.sentry.provider.db.service.thrift.SentryPolicyService$Processor$alter_sentry_role_grant_privilege.getResult(SentryPolicyService.java:1222)
              at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
              at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
              at org.apache.sentry.provider.db.service.thrift.SentryProcessorWrapper.process(SentryProcessorWrapper.java:35)
              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)
      

      This causes Sentry to report an unknown error back:

      2016-11-28 20:12:19,506 (pool-7-thread-10) [ERROR - org.apache.sentry.provider.db.service.thrift.Sent
      ryPolicyStoreProcessor.alter_sentry_role_grant_privilege(SentryPolicyStoreProcessor.java:309)] Unknow
      n error for request: TAlterSentryRoleGrantPrivilegeRequest(protocol_version:2, requestorUserName:akol
      b, roleName:r3, privilege:TSentryPrivilege(privilegeScope:, serverName:, dbName:, tableName:, URI:, a
      ction:, grantOption:UNSET, columnName:), privileges:[TSentryPrivilege(privilegeScope:, serverName:, dbName:, tableName:, URI:, action:, grantOption:UNSET, columnName:)]), message: The transaction has reached max retry number, will not retry again.
      java.lang.Exception: The transaction has reached max retry number, will not retry again.
              at org.apache.sentry.provider.db.service.persistent.TransactionManager.executeTransactionWithRetry(TransactionManager.java:103)
              at org.apache.sentry.provider.db.service.persistent.SentryStore.alterSentryRoleGrantPrivileges(SentryStore.java:367)
              at org.apache.sentry.provider.db.service.thrift.SentryPolicyStoreProcessor.alter_sentry_role_grant_privilege(SentryPolicyStoreProcessor.java:280)
              at org.apache.sentry.provider.db.service.thrift.SentryPolicyService$Processor$alter_sentry_role_grant_privilege.getResult(SentryPolicyService.java:1237)
              at org.apache.sentry.provider.db.service.thrift.SentryPolicyService$Processor$alter_sentry_role_grant_privilege.getResult(SentryPolicyService.java:1222)
              at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
              at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
              at org.apache.sentry.provider.db.service.thrift.SentryProcessorWrapper.process(SentryProcessorWrapper.java:35)
              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)
      Caused by: javax.jdo.JDODataStoreException: Insert of object "org.apache.sentry.provider.db.service.model.MSentryPrivilege@6bbfd4c9" using statement "INSERT INTO `SENTRY_DB_PRIVILEGE` (`DB_PRIVILEGE_ID`,`SERVER_NAME`,`WITH_GRANT_OPTION`,`CREATE_TIME`,`TABLE_NAME`,`URI`,`ACTION`,`COLUMN_NAME`,`DB_NAME`,`PRIVILEGE_SCOPE`) VALUES (?,?,?,?,?,?,?,?,?,?)" failed : Column 'WITH_GRANT_OPTION' cannot be null
      NestedThrowables:
      com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'WITH_GRANT_OPTION' cannot be null
              at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:451)
              at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:732)
              at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:752)
              at org.apache.sentry.provider.db.service.persistent.SentryStore.alterSentryRoleGrantPrivilegeCore(SentryStore.java:438)
              at org.apache.sentry.provider.db.service.persistent.SentryStore.access$500(SentryStore.java:95)
              at org.apache.sentry.provider.db.service.persistent.SentryStore$8.execute(SentryStore.java:374)
              at org.apache.sentry.provider.db.service.persistent.TransactionManager.executeTransaction(TransactionManager.java:72)
              at org.apache.sentry.provider.db.service.persistent.TransactionManager.executeTransactionWithRetry(TransactionManager.java:93)
              ... 12 more
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'WITH_GRANT_OPTION' cannot be null
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
              at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
              at com.mysql.jdbc.Util.getInstance(Util.java:387)
              at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:934)
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3966)
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3902)
              at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2526)
              at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2673)
              at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2549)
              at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
              at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2073)
              at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2009)
              at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5098)
              at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1994)
              at com.jolbox.bonecp.PreparedStatementHandle.executeUpdate(PreparedStatementHandle.java:205)
              at org.datanucleus.store.rdbms.ParamLoggingPreparedStatement.executeUpdate(ParamLoggingPreparedStatement.java:399)
              at org.datanucleus.store.rdbms.SQLController.executeStatementUpdate(SQLController.java:439)
              at org.datanucleus.store.rdbms.request.InsertRequest.execute(InsertRequest.java:410)
              at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertTable(RDBMSPersistenceHandler.java:167)
              at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.insertObject(RDBMSPersistenceHandler.java:143)
              at org.datanucleus.state.JDOStateManager.internalMakePersistent(JDOStateManager.java:3784)
              at org.datanucleus.state.JDOStateManager.makePersistent(JDOStateManager.java:3760)
              at org.datanucleus.ExecutionContextImpl.persistObjectInternal(ExecutionContextImpl.java:2219)
              at org.datanucleus.ExecutionContextImpl.persistObjectWork(ExecutionContextImpl.java:2065)
              at org.datanucleus.ExecutionContextImpl.persistObject(ExecutionContextImpl.java:1913)
              at org.datanucleus.ExecutionContextThreadedImpl.persistObject(ExecutionContextThreadedImpl.java:217)
              at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:727)
              ... 18 more
      

      More over, this transaction (that is always failing) is retried multiple times. The code should just check that that's not the case.

        Attachments

        1. SENTRY-1548.001.patch
          5 kB
          Krishna Kalyan
        2. SENTRY-1548.001-sentry-ha-redesign.patch
          11 kB
          Krishna Kalyan
        3. SENTRY-1548.002.patch
          4 kB
          Krishna Kalyan
        4. SENTRY-1548.002-sentry-ha-redesign.patch
          11 kB
          Krishna Kalyan
        5. SENTRY-1548.003.patch
          5 kB
          Krishna Kalyan
        6. SENTRY-1548.005.patch
          6 kB
          Krishna Kalyan
        7. SENTRY-1548.006.patch
          16 kB
          Krishna Kalyan
        8. SENTRY-1548.007.patch
          12 kB
          Krishna Kalyan
        9. SENTRY-1548.008.patch
          11 kB
          Krishna Kalyan
        10. SENTRY-1548.009.patch
          11 kB
          Krishna Kalyan

          Issue Links

            Activity

              People

              • Assignee:
                kkalyan Krishna Kalyan
                Reporter:
                akolb Alex Kolbasov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: