Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-27698

Migrate meta locations from zookeeper to master data may not always possible if we migrate from 1.x HBase

    XMLWordPrintableJSON

Details

    • Bug
    • Status: In Progress
    • Major
    • Resolution: Unresolved
    • 2.5.0
    • 2.7.0
    • migration
    • None

    Description

      In HBase 1.x versions meta server location from zookeeper will be removed when the server stopped. In such cases migrating to 2.5.x branches may not create any meta entries in master data. So in case if we could not find the meta location from zookeeper we can get meta location from wal directories with .meta extension and add to master data.

        private void tryMigrateMetaLocationsFromZooKeeper() throws IOException, KeeperException {
          // try migrate data from zookeeper
          try (ResultScanner scanner =
            masterRegion.getScanner(new Scan().addFamily(HConstants.CATALOG_FAMILY))) {
            if (scanner.next() != null) {
              // notice that all replicas for a region are in the same row, so the migration can be
              // done with in a one row put, which means if we have data in catalog family then we can
              // make sure that the migration is done.
              LOG.info("The {} family in master local region already has data in it, skip migrating...",
                HConstants.CATALOG_FAMILY_STR);
              return;
            }
          }
          // start migrating
          byte[] row = CatalogFamilyFormat.getMetaKeyForRegion(RegionInfoBuilder.FIRST_META_REGIONINFO);
          Put put = new Put(row);
          List<String> metaReplicaNodes = zooKeeper.getMetaReplicaNodes();
          StringBuilder info = new StringBuilder("Migrating meta locations:");
          for (String metaReplicaNode : metaReplicaNodes) {
            int replicaId = zooKeeper.getZNodePaths().getMetaReplicaIdFromZNode(metaReplicaNode);
            RegionState state = MetaTableLocator.getMetaRegionState(zooKeeper, replicaId);
            info.append(" ").append(state);
            put.setTimestamp(state.getStamp());
            MetaTableAccessor.addRegionInfo(put, state.getRegion());
            if (state.getServerName() != null) {
              MetaTableAccessor.addLocation(put, state.getServerName(), HConstants.NO_SEQNUM, replicaId);
            }
            put.add(CellBuilderFactory.create(CellBuilderType.SHALLOW_COPY).setRow(put.getRow())
              .setFamily(HConstants.CATALOG_FAMILY)
              .setQualifier(RegionStateStore.getStateColumn(replicaId)).setTimestamp(put.getTimestamp())
              .setType(Cell.Type.Put).setValue(Bytes.toBytes(state.getState().name())).build());
          }
          if (!put.isEmpty()) {
            LOG.info(info.toString());
            masterRegion.update(r -> r.put(put));
          } else {
            LOG.info("No meta location available on zookeeper, skip migrating...");
          }
        }
      

      Attachments

        Issue Links

          Activity

            People

              rajeshbabu Rajeshbabu Chintaguntla
              rajeshbabu Rajeshbabu Chintaguntla
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated: