@Override
  public boolean refreshPrivileges(HiveObjectRef objToRefresh, String authorizer, PrivilegeBag grantPrivileges)
      throws InvalidObjectException, MetaException, NoSuchObjectException {
    boolean committed = false;
    try {
      openTransaction();
      Set<HiveObjectPrivilege> revokePrivilegeSet
          = new TreeSet<>(new PrivilegeWithoutCreateTimeComparator());
      Set<HiveObjectPrivilege> grantPrivilegeSet
          = new TreeSet<>(new PrivilegeWithoutCreateTimeComparator());

      List<HiveObjectPrivilege> grants = null;
      String catName = objToRefresh.isSetCatName() ? objToRefresh.getCatName() :
          getDefaultCatalog(conf);
      switch (objToRefresh.getObjectType()) {
      case DATABASE:
        try {
          grants = this.listDBGrantsAll(catName, objToRefresh.getDbName(), authorizer);
        } catch (Exception e) {
          throw new MetaException(e.getMessage());
        }
        break;
      case DATACONNECTOR:
        try {
          grants = this.listDCGrantsAll(objToRefresh.getObjectName(), authorizer);
        } catch (Exception e) {
          throw new MetaException(e.getMessage());
        }
        break;
      case TABLE:
        grants = listTableGrantsAll(catName, objToRefresh.getDbName(), objToRefresh.getObjectName(), authorizer);
        break;
      case COLUMN:
        Preconditions.checkArgument(objToRefresh.getColumnName()==null, "columnName must be null");
        grants = getTableAllColumnGrants(catName, objToRefresh.getDbName(),
                objToRefresh.getObjectName(), authorizer);
        break;
      default:
        throw new MetaException("Unexpected object type " + objToRefresh.getObjectType());
      }
      revokePrivilegeSet.addAll(grants);

      // Optimize revoke/grant list, remove the overlapping
      if (grantPrivileges.getPrivileges() != null) {
        for (HiveObjectPrivilege grantPrivilege : grantPrivileges.getPrivileges()) {
          if (revokePrivilegeSet.contains(grantPrivilege)) {
            revokePrivilegeSet.remove(grantPrivilege);
          } else {
            grantPrivilegeSet.add(grantPrivilege);
          }
        }
      }
      if (!revokePrivilegeSet.isEmpty()) {
        LOG.debug("Found " + revokePrivilegeSet.size() + " new revoke privileges to be synced.");
        PrivilegeBag remainingRevokePrivileges = new PrivilegeBag();
        for (HiveObjectPrivilege revokePrivilege : revokePrivilegeSet) {
          remainingRevokePrivileges.addToPrivileges(revokePrivilege);
        }
        revokePrivileges(remainingRevokePrivileges, false);
      } else {
        LOG.debug("No new revoke privileges are required to be synced.");
      }
      if (!grantPrivilegeSet.isEmpty()) {
        LOG.debug("Found " + grantPrivilegeSet.size() + " new grant privileges to be synced.");
        PrivilegeBag remainingGrantPrivileges = new PrivilegeBag();
        for (HiveObjectPrivilege grantPrivilege : grantPrivilegeSet) {
          remainingGrantPrivileges.addToPrivileges(grantPrivilege);
        }
        grantPrivileges(remainingGrantPrivileges);
      } else {
        LOG.debug("No new grant privileges are required to be synced.");
      }
      committed = commitTransaction();
    } finally {
      rollbackAndCleanup(committed, null);
    }
    return committed;
  }
Add role names of parentRoles and its parents to processedRoles
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java