You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2019/07/19 22:44:07 UTC
[hbase-operator-tools] branch master updated: HBASE-22717 [HBCK2]
Expose replication fixes from hbck1 (#13)
This is an automated email from the ASF dual-hosted git repository.
stack pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase-operator-tools.git
The following commit(s) were added to refs/heads/master by this push:
new 6bcaeb9 HBASE-22717 [HBCK2] Expose replication fixes from hbck1 (#13)
6bcaeb9 is described below
commit 6bcaeb9ad053d60ac4d5d51b9d8d796b5e919ef8
Author: Michael Stack <sa...@users.noreply.github.com>
AuthorDate: Fri Jul 19 15:44:02 2019 -0700
HBASE-22717 [HBCK2] Expose replication fixes from hbck1 (#13)
* HBASE-22717 [HBCK2] Expose replication fixes from hbck1
Finds undeleted queues and replication barriers. Removes
them if --fix is passed.
---
.../main/java/org/apache/hbase/FileSystemFsck.java | 1 -
.../src/main/java/org/apache/hbase/HBCK2.java | 21 +++++++-
.../{FileSystemFsck.java => ReplicationFsck.java} | 61 ++++++----------------
.../java/org/apache/hbase/hbck1/HBaseFsck.java | 9 ++--
4 files changed, 39 insertions(+), 53 deletions(-)
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java b/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
index 89b0d73..28fe2ec 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
@@ -100,7 +100,6 @@ public class FileSystemFsck implements Closeable {
hbaseFsck.setFixHdfsOverlaps(fix);
hbaseFsck.setFixTableOrphans(fix);
*/
- hbaseFsck.setShouldRerun();
hbaseFsck.offlineHbck();
} catch (ClassNotFoundException | InterruptedException e) {
throw new IOException(e);
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java b/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
index 70a8ce2..a1c3d47 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java
@@ -81,6 +81,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
private static final String UNASSIGNS = "unassigns";
private static final String BYPASS = "bypass";
private static final String FILESYSTEM = "filesystem";
+ private static final String REPLICATION = "replication";
private static final String VERSION = "version";
private static final String SET_REGION_STATE = "setRegionState";
private static final String SCHEDULE_RECOVERIES = "scheduleRecoveries";
@@ -292,7 +293,7 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
// out.println(" -fixVersionFile Try to fix missing hbase.version file in hdfs.");
// out.println(" -fixReferenceFiles Try to offline lingering reference store files");
// out.println(" -fixHFileLinks Try to offline lingering HFileLinks");
- writer.println(" " + FILESYSTEM + " [OPTIONS] [<TABLENAME...]");
+ writer.println(" " + FILESYSTEM + " [OPTIONS] [<TABLENAME>...]");
writer.println(" Options:");
writer.println(" -f, --fix sideline corrupt hfiles, bad links, and references.");
writer.println(" Report on corrupt hfiles, references, broken links, and integrity.");
@@ -302,6 +303,13 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
writer.println(" restores 'hbase.version' if missing. Interacts with the filesystem only!");
writer.println(" Modified regions need to be reopened to pick-up changes.");
writer.println();
+ writer.println(" " + REPLICATION + " [OPTIONS] [<TABLENAME>...]");
+ writer.println(" Options:");
+ writer.println(" -f, --fix fix any replication issues found.");
+ writer.println(" Looks for undeleted replication queues and deletes them if passed the");
+ writer.println(" '--fix' option. Pass a table name to check for replication barrier and");
+ writer.println(" purge if '--fix'.");
+ writer.println();
writer.println(" " + SET_REGION_STATE + " <ENCODED_REGIONNAME> <STATE>");
writer.println(" Possible region states:");
writer.println(" OFFLINE, OPENING, OPEN, CLOSING, CLOSED, SPLITTING, SPLIT,");
@@ -553,6 +561,17 @@ public class HBCK2 extends Configured implements org.apache.hadoop.util.Tool {
}
break;
+ case REPLICATION:
+ try (ClusterConnection connection = connect()) {
+ checkHBCKSupport(connection, command);
+ try (ReplicationFsck replicationFsck = new ReplicationFsck(getConf())) {
+ if (replicationFsck.fsck(options, purgeFirst(commands)) != 0) {
+ return EXIT_FAILURE;
+ }
+ }
+ }
+ break;
+
case SCHEDULE_RECOVERIES:
if (commands.length < 2) {
usage(options, command + " takes one or more serverNames");
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java b/hbase-hbck2/src/main/java/org/apache/hbase/ReplicationFsck.java
similarity index 54%
copy from hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
copy to hbase-hbck2/src/main/java/org/apache/hbase/ReplicationFsck.java
index 89b0d73..22be5a7 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/FileSystemFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/ReplicationFsck.java
@@ -20,15 +20,10 @@ package org.apache.hbase;
import java.io.Closeable;
import java.io.IOException;
import java.util.Collection;
-import java.util.stream.Collectors;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.hadoop.hbase.replication.ReplicationException;
import org.apache.hbase.hbck1.HBaseFsck;
-import org.apache.hbase.hbck1.HFileCorruptionChecker;
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.hbase.thirdparty.org.apache.commons.cli.DefaultParser;
@@ -37,18 +32,13 @@ import org.apache.hbase.thirdparty.org.apache.commons.cli.Options;
import org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException;
/**
- * Checks and repairs for hbase filesystem.
+ * Checks and repairs for hbase replication.
*/
-public class FileSystemFsck implements Closeable {
+public class ReplicationFsck implements Closeable {
private final Configuration configuration;
- private FileSystem fs;
- private Path rootDir;
- FileSystemFsck(Configuration conf) throws IOException {
+ ReplicationFsck(Configuration conf) throws IOException {
this.configuration = conf;
- this.rootDir = FSUtils.getRootDir(this.configuration);
- this.fs = rootDir.getFileSystem(this.configuration);
-
}
@Override
@@ -70,39 +60,20 @@ public class FileSystemFsck implements Closeable {
return -1;
}
boolean fix = commandLine.hasOption(fixOption.getOpt());
- // Before we start make sure of the version file.
- if (fix && !HBaseFsck.versionFileExists(this.fs, this.rootDir)) {
- HBaseFsck.versionFileCreate(this.configuration, this.fs, this.rootDir);
- }
- // Iterate over list of tablenames or encoded region names passed.
try (HBaseFsck hbaseFsck = new HBaseFsck(this.configuration)) {
- // Check hfiles.
- HFileCorruptionChecker hfcc = hbaseFsck.createHFileCorruptionChecker(fix);
- hbaseFsck.setHFileCorruptionChecker(hfcc);
+ hbaseFsck.setFixReplication(fix);
+ hbaseFsck.checkAndFixReplication();
Collection<String> tables = commandLine.getArgList();
- Collection<Path> tableDirs = tables.isEmpty()?
- FSUtils.getTableDirs(this.fs, this.rootDir):
- tables.stream().map(t -> FSUtils.getTableDir(this.rootDir, TableName.valueOf(t))).
- collect(Collectors.toList());
- hfcc.checkTables(tableDirs);
- hfcc.report(hbaseFsck.getErrors());
- // Now check links.
- hbaseFsck.setFixReferenceFiles(fix);
- hbaseFsck.setFixHFileLinks(fix);
- hbaseFsck.setCheckHdfs(true);
- /*
- The below are too radical for hbck2. They are filesystem changes only.
- Need to connect them to hbase:meta and master; master should repair
- holes and overlaps and adopt regions.
-
- hbaseFsck.setFixHdfsOrphans(fix);
- hbaseFsck.setFixHdfsHoles(fix);
- hbaseFsck.setFixHdfsOverlaps(fix);
- hbaseFsck.setFixTableOrphans(fix);
- */
- hbaseFsck.setShouldRerun();
- hbaseFsck.offlineHbck();
- } catch (ClassNotFoundException | InterruptedException e) {
+ if (tables != null && !tables.isEmpty()) {
+ // Below needs connection to be up; uses admin.
+ hbaseFsck.connect();
+ hbaseFsck.setCleanReplicationBarrier(fix);
+ for (String table: tables) {
+ hbaseFsck.setCleanReplicationBarrierTable(table);
+ hbaseFsck.cleanReplicationBarrier();
+ }
+ }
+ } catch (ClassNotFoundException | ReplicationException e) {
throw new IOException(e);
}
return 0;
diff --git a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
index 59b6f71..4d16591 100644
--- a/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
+++ b/hbase-hbck2/src/main/java/org/apache/hbase/hbck1/HBaseFsck.java
@@ -556,7 +556,6 @@ public class HBaseFsck extends Configured implements Closeable {
try {
IOUtils.closeQuietly(hbckOutFd);
FSUtils.delete(FSUtils.getCurrentFileSystem(getConf()), hbckLockPath, true);
- LOG.info("Finishing hbck");
return;
} catch (IOException ioe) {
LOG.info("Failed to delete " + hbckLockPath + ", try="
@@ -613,8 +612,6 @@ public class HBaseFsck extends Configured implements Closeable {
}
});
- LOG.info("Launching hbck");
-
connection = ConnectionFactory.createConnection(getConf());
admin = connection.getAdmin();
meta = connection.getTable(TableName.META_TABLE_NAME);
@@ -2080,7 +2077,7 @@ public class HBaseFsck extends Configured implements Closeable {
}
private ZKWatcher createZooKeeperWatcher() throws IOException {
- return new ZKWatcher(getConf(), "hbase Fsck", new Abortable() {
+ return new ZKWatcher(getConf(), "HBCK2", new Abortable() {
@Override
public void abort(String why, Throwable e) {
LOG.error(why, e);
@@ -3770,7 +3767,7 @@ public class HBaseFsck extends Configured implements Closeable {
return hbi;
}
- private void checkAndFixReplication() throws ReplicationException {
+ public void checkAndFixReplication() throws ReplicationException {
ReplicationChecker checker = new ReplicationChecker(getConf(), zkw, errors);
checker.checkUnDeletedQueues();
@@ -5382,7 +5379,7 @@ public class HBaseFsck extends Configured implements Closeable {
}
if (regionNames.size() <= 0) {
errors.reportError(ErrorReporter.ERROR_CODE.INVALID_TABLE,
- "there is no barriers of this table: " + cleanReplicationBarrierTable);
+ "No replication barrier(s) on table: " + cleanReplicationBarrierTable);
return;
}
ReplicationQueueStorage queueStorage =