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

Acquire lock in MetaDataEndPointImpl.addRowsToChildViews() before calling doGetTable()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.5.0
    • Labels:
      None

      Description

      Rather than acquiring the row lock in doGetTable and then letting the lock be released and then getting it again right afterwards, it'd be better to acquire the lock upfront and pass it into doGetTable, like this:

          private void addRowsToChildViews(List<Mutation> tableMetadata, List<Mutation> mutationsForAddingColumnsToViews, byte[] schemaName, byte[] tableName,
                  List<ImmutableBytesPtr> invalidateList, long clientTimeStamp, TableViewFinderResult childViewsResult,
                  Region region, List<RowLock> locks) throws IOException, SQLException {
              for (Result viewResult : childViewsResult.getResults()) {
                  byte[][] rowViewKeyMetaData = new byte[3][];
                  getVarChars(viewResult.getRow(), 3, rowViewKeyMetaData);
                  byte[] viewTenantId = rowViewKeyMetaData[PhoenixDatabaseMetaData.TENANT_ID_INDEX];
                  byte[] viewSchemaName = rowViewKeyMetaData[PhoenixDatabaseMetaData.SCHEMA_NAME_INDEX];
                  byte[] viewName = rowViewKeyMetaData[PhoenixDatabaseMetaData.TABLE_NAME_INDEX];
                  // lock the rows corresponding to views so that no other thread can modify the view meta-data
                  // TODO: modify acquireLock to return the RowLock
                  RowLock rowLock = acquireLock(region, viewKey, locks);
                  byte[] viewKey = SchemaUtil.getTableKey(viewTenantId, viewSchemaName, viewName);
                  PTable view = doGetTable(viewKey, clientTimeStamp, rowLock);
      
                  if (view.getBaseColumnCount() == QueryConstants.DIVORCED_VIEW_BASE_COLUMN_COUNT) {
                      // if a view has divorced itself from the base table, we don't allow schema changes
                      // to be propagated to it.
                      return;
                  }
      

        Attachments

          Activity

            People

            • Assignee:
              samarthjain Samarth Jain
              Reporter:
              jamestaylor James Taylor
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: