[enhancement](recover) Support skipping bad tablet in select by session variable (#30241)

In some scenarios, user has a huge amount of data and only a single replica was specified when creating the table, if one of the tablet is damaged, the table will not be able to be select. If the user does not care about the integrity of the data, they can use this variable to temporarily skip the bad tablet for querying and load the remaining data into a new table.
This commit is contained in:
zxealous
2024-01-23 16:56:01 +08:00
committed by yiguolei
parent 1b9f1f6483
commit 4cbacb5b39
5 changed files with 27 additions and 0 deletions

View File

@ -765,6 +765,9 @@ public class OlapScanNode extends ScanNode {
// random shuffle List && only collect one copy
List<Replica> replicas = tablet.getQueryableReplicas(visibleVersion, skipMissingVersion);
if (replicas.isEmpty()) {
if (ConnectContext.get().getSessionVariable().skipBadTablet) {
continue;
}
LOG.warn("no queryable replica found in tablet {}. visible version {}", tabletId, visibleVersion);
StringBuilder sb = new StringBuilder(
"Failed to get scan range, no queryable replica found in tablet: " + tabletId);

View File

@ -320,6 +320,8 @@ public class SessionVariable implements Serializable, Writable {
public static final String SKIP_MISSING_VERSION = "skip_missing_version";
public static final String SKIP_BAD_TABLET = "skip_bad_tablet";
public static final String ENABLE_PUSH_DOWN_NO_GROUP_AGG = "enable_push_down_no_group_agg";
public static final String ENABLE_CBO_STATISTICS = "enable_cbo_statistics";
@ -1146,6 +1148,14 @@ public class SessionVariable implements Serializable, Writable {
@VariableMgr.VarAttr(name = SKIP_MISSING_VERSION)
public boolean skipMissingVersion = false;
// This variable is used to control whether to skip the bad tablet.
// In some scenarios, user has a huge amount of data and only a single replica was specified when creating
// the table, if one of the tablet is damaged, the table will not be able to be select. If the user does not care
// about the integrity of the data, they can use this variable to temporarily skip the bad tablet for querying and
// load the remaining data into a new table.
@VariableMgr.VarAttr(name = SKIP_BAD_TABLET)
public boolean skipBadTablet = false;
// This variable is used to avoid FE fallback to the original parser. When we execute SQL in regression tests
// for nereids, fallback will cause the Doris return the correct result although the syntax is unsupported
// in nereids for some mistaken modification. You should set it on the
@ -2853,6 +2863,7 @@ public class SessionVariable implements Serializable, Writable {
tResult.setEnableParallelScan(enableParallelScan);
tResult.setParallelScanMaxScannersCount(parallelScanMaxScannersCount);
tResult.setParallelScanMinRowsPerScanner(parallelScanMinRowsPerScanner);
tResult.setSkipBadTablet(skipBadTablet);
return tResult;
}