Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-5750

Upsert on immutable table fails with AccessDeniedException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 4.15.0, 4.14.3
    • None
    • None
    • None

    Description

      // code placeholder
      In TableDDLPermissionsIT
      
      @Test
      public void testUpsertIntoImmutableTable() throws Throwable {
          startNewMiniCluster();
          final String schema = "TEST_INDEX_VIEW";
          final String tableName = "TABLE_DDL_PERMISSION_IT";
          final String phoenixTableName = schema + "." + tableName;
          grantSystemTableAccess();
          try {
              superUser1.runAs(new PrivilegedExceptionAction<Void>() {
                  @Override
                  public Void run() throws Exception {
                      try {
                          verifyAllowed(createSchema(schema), superUser1);
                          verifyAllowed(onlyCreateTable(phoenixTableName), superUser1);
                      } catch (Throwable e) {
                          if (e instanceof Exception) {
                              throw (Exception)e;
                          } else {
                              throw new Exception(e);
                          }
                      }
                      return null;
                  }
              });
      
              if (isNamespaceMapped) {
                  grantPermissions(unprivilegedUser.getShortName(), schema, Action.WRITE, Action.READ,Action.EXEC);
              }
      
              // we should be able to read the data from another index as well to which we have not given any access to
              // this user
              verifyAllowed(upsertRowsIntoTable(phoenixTableName), unprivilegedUser);
          } finally {
              revokeAll();
          }
      }
      
      
      
      in BasePermissionsIT:
      AccessTestAction onlyCreateTable(final String tableName) throws SQLException {
          return new AccessTestAction() {
              @Override
              public Object run() throws Exception {
                  try (Connection conn = getConnection(); Statement stmt = conn.createStatement()) {
                      assertFalse(stmt.execute("CREATE IMMUTABLE TABLE " + tableName
                              + "(pk INTEGER not null primary key, data VARCHAR, val integer)"));
                  }
                  return null;
              }
          };
      }
      
      AccessTestAction upsertRowsIntoTable(final String tableName) throws SQLException {
          return new AccessTestAction() {
              @Override
              public Object run() throws Exception {
                  try (Connection conn = getConnection()) {
                      try (PreparedStatement pstmt = conn.prepareStatement(
                              "UPSERT INTO " + tableName + " values(?, ?, ?)")) {
                          for (int i = 0; i < NUM_RECORDS; i++) {
                              pstmt.setInt(1, i);
                              pstmt.setString(2, Integer.toString(i));
                              pstmt.setInt(3, i);
                              assertEquals(1, pstmt.executeUpdate());
                          }
                      }
                      conn.commit();
                  }
                  return null;
              }
          };
      }

       

      Attachments

        1. PHOENIX-5750.4.x-HBase-1.3.v2.patch
          7 kB
          Swaroopa Kadam
        2. PHOENIX-5750.4.x-HBase-1.3.v1.patch
          7 kB
          Swaroopa Kadam

        Issue Links

          Activity

            People

              swaroopa Swaroopa Kadam
              swaroopa Swaroopa Kadam
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

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