[minor](log) add details for unqueryable replicas (#19792)

Add a new FE config: show_details_for_unaccessible_tablet.
Default is false, when set to true, if a query is unable to select a healthy replica,
the detailed information of all the replicas of the tablet including the specific reason why they are unqueryable,
will be printed out.
This commit is contained in:
Mingyu Chen
2023-05-19 08:53:57 +08:00
committed by GitHub
parent dc8a992bba
commit 14620a6766
4 changed files with 52 additions and 12 deletions

View File

@ -1968,6 +1968,13 @@ public class Config extends ConfigBase {
* optimization of table structures
*
*/
@ConfField(mutable = true, masterOnly = false)
@ConfField(mutable = true)
public static boolean enable_query_hit_stats = false;
@ConfField(mutable = true, description = {
"设置为 true,如果查询无法选择到健康副本时,会打印出该tablet所有副本的详细信息," + "以及不可查询的具体原因。",
"When set to true, if a query is unable to select a healthy replica, "
+ "the detailed information of all the replicas of the tablet,"
+ " including the specific reason why they are unqueryable, will be printed out."})
public static boolean show_details_for_unaccessible_tablet = false;
}

View File

@ -277,6 +277,25 @@ public class Tablet extends MetaObject implements Writable {
return allQueryableReplica;
}
public String getDetailsStatusForQuery(long visibleVersion) {
StringBuilder sb = new StringBuilder("Visible Replicas:");
sb.append("Visible version: ").append(visibleVersion);
sb.append(", Replicas: ");
for (Replica replica : replicas) {
sb.append(replica.toString());
}
sb.append(", Backends: ");
for (Replica replica : replicas) {
Backend be = Env.getCurrentSystemInfo().getBackend(replica.getBackendId());
if (be == null) {
sb.append("Backend [id=" + id + ", not exists]");
} else {
sb.append(be.getHealthyStatus());
}
}
return sb.toString();
}
public Replica getReplicaById(long replicaId) {
for (Replica replica : replicas) {
if (replica.getId() == replicaId) {

View File

@ -737,14 +737,16 @@ public class OlapScanNode extends ScanNode {
// random shuffle List && only collect one copy
List<Replica> replicas = tablet.getQueryableReplicas(visibleVersion);
if (replicas.isEmpty()) {
LOG.error("no queryable replica found in tablet {}. visible version {}",
tabletId, visibleVersion);
if (LOG.isDebugEnabled()) {
for (Replica replica : tablet.getReplicas()) {
LOG.debug("tablet {}, replica: {}", tabletId, replica.toString());
}
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);
if (Config.show_details_for_unaccessible_tablet) {
sb.append(". Reason: ").append(tablet.getDetailsStatusForQuery(visibleVersion));
}
throw new UserException("Failed to get scan range, no queryable replica found in tablet: " + tabletId);
if (LOG.isDebugEnabled()) {
LOG.debug(sb.toString());
}
throw new UserException(sb.toString());
}
int useFixReplica = -1;

View File

@ -601,15 +601,20 @@ public class Backend implements Writable {
Backend backend = (Backend) obj;
return (id == backend.id) && (host.equals(backend.host)) && (heartbeatPort == backend.heartbeatPort)
&& (bePort == backend.bePort) && (isAlive.get() == backend.isAlive.get());
return (id == backend.id) && (host.equals(backend.host)) && (heartbeatPort == backend.heartbeatPort) && (bePort
== backend.bePort) && (isAlive.get() == backend.isAlive.get());
}
@Override
public String toString() {
return "Backend [id=" + id + ", host=" + host + ", heartbeatPort=" + heartbeatPort + ", alive=" + isAlive.get()
+ ", lastStartTime=" + TimeUtils.longToTimeString(lastStartTime)
+ ", tags: " + tagMap + "]";
+ ", lastStartTime=" + TimeUtils.longToTimeString(lastStartTime) + ", tags: " + tagMap + "]";
}
public String getHealthyStatus() {
return "Backend [id=" + id + ", isDecommission: " + isDecommissioned + ", backendState: " + backendState
+ ", backendStatus: " + backendStatus + ", isAlive: " + isAlive.get() + ", lastUpdateTime: "
+ TimeUtils.longToTimeString(lastUpdateMs);
}
public String getOwnerClusterName() {
@ -746,6 +751,13 @@ public class Backend implements Writable {
public volatile boolean isQueryDisabled = false;
@SerializedName("isLoadDisabled")
public volatile boolean isLoadDisabled = false;
@Override
public String toString() {
return "[" + "lastSuccessReportTabletsTime='" + lastSuccessReportTabletsTime + '\''
+ ", lastStreamLoadTime=" + lastStreamLoadTime + ", isQueryDisabled=" + isQueryDisabled
+ ", isLoadDisabled=" + isLoadDisabled + "]";
}
}
public Tag getLocationTag() {