@Override
  public int execute() throws HiveException, IOException, TException, MetastoreException {
    try {
      Msck msck = new Msck(false, false);
      msck.init(Msck.getMsckConf(context.getDb().getConf()));
      msck.updateExpressionProxy(getProxyClass(context.getDb().getConf()));

      TableName tableName = HiveTableName.of(desc.getTableName());

      long partitionExpirySeconds = -1L;
      try (HiveMetaStoreClient msc = new HiveMetaStoreClient(context.getConf())) {
        boolean msckEnablePartitionRetention = MetastoreConf.getBoolVar(context.getConf(),
            MetastoreConf.ConfVars.MSCK_REPAIR_ENABLE_PARTITION_RETENTION);
        if (msckEnablePartitionRetention) {
          Table table = msc.getTable(SessionState.get().getCurrentCatalog(), tableName.getDb(), tableName.getTable());
          String qualifiedTableName = Warehouse.getCatalogQualifiedTableName(table);
          partitionExpirySeconds = PartitionManagementTask.getRetentionPeriodInSeconds(table);
          LOG.info("{} - Retention period ({}s) for partition is enabled for MSCK REPAIR..", qualifiedTableName,
              partitionExpirySeconds);
        }
      }
      MsckInfo msckInfo = new MsckInfo(SessionState.get().getCurrentCatalog(), tableName.getDb(), tableName.getTable(),
          desc.getFilterExp(), desc.getResFile(), desc.isRepairPartitions(),
          desc.isAddPartitions(), desc.isDropPartitions(), partitionExpirySeconds);
      return msck.repair(msckInfo);
    } catch (MetaException | MetastoreException e) {
      LOG.error("Unable to create msck instance.", e);
      throw e;
    } catch (SemanticException e) {
      LOG.error("Msck failed.", e);
      return 1;
    }
  }
Operation process of metastore check.

MetastoreCheck, see if the data in the metastore matches what is on the dfs. Current version checks for tables
and partitions that are either missing on disk on in the metastore.
ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckOperation.java