HBASE-26025 Add a flag to mark if the IOError can be solved by retry in thrift IOError (#3429)

Signed-off-by: Reid Chan <reidchan@apache.org>
This commit is contained in:
YutSean 2021-06-28 10:25:42 +08:00 committed by GitHub
parent fd2f8a581f
commit b2f8ec993e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 248 additions and 44 deletions

View File

@ -33,6 +33,7 @@ import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@ -1220,6 +1221,7 @@ public class ThriftHBaseServiceHandler extends HBaseServiceHandler implements Hb
private static IOError getIOError(Throwable throwable) {
IOError error = new IOErrorWithCause(throwable);
error.setMessage(Throwables.getStackTraceAsString(throwable));
error.setCanRetry(!(throwable instanceof DoNotRetryIOException));
return error;
}

View File

@ -17,15 +17,18 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("IOError");
private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField CAN_RETRY_FIELD_DESC = new org.apache.thrift.protocol.TField("canRetry", org.apache.thrift.protocol.TType.BOOL, (short)2);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new IOErrorStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new IOErrorTupleSchemeFactory();
public @org.apache.thrift.annotation.Nullable java.lang.String message; // required
public boolean canRetry; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
MESSAGE((short)1, "message");
MESSAGE((short)1, "message"),
CAN_RETRY((short)2, "canRetry");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
@ -43,6 +46,8 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
switch(fieldId) {
case 1: // MESSAGE
return MESSAGE;
case 2: // CAN_RETRY
return CAN_RETRY;
default:
return null;
}
@ -84,11 +89,15 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
}
// isset id assignments
private static final int __CANRETRY_ISSET_ID = 0;
private byte __isset_bitfield = 0;
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.CAN_RETRY, new org.apache.thrift.meta_data.FieldMetaData("canRetry", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(IOError.class, metaDataMap);
}
@ -97,19 +106,24 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
}
public IOError(
java.lang.String message)
java.lang.String message,
boolean canRetry)
{
this();
this.message = message;
this.canRetry = canRetry;
setCanRetryIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public IOError(IOError other) {
__isset_bitfield = other.__isset_bitfield;
if (other.isSetMessage()) {
this.message = other.message;
}
this.canRetry = other.canRetry;
}
public IOError deepCopy() {
@ -119,6 +133,8 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
@Override
public void clear() {
this.message = null;
setCanRetryIsSet(false);
this.canRetry = false;
}
@org.apache.thrift.annotation.Nullable
@ -146,15 +162,46 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
}
}
public boolean isCanRetry() {
return this.canRetry;
}
public IOError setCanRetry(boolean canRetry) {
this.canRetry = canRetry;
setCanRetryIsSet(true);
return this;
}
public void unsetCanRetry() {
__isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CANRETRY_ISSET_ID);
}
/** Returns true if field canRetry is set (has been assigned a value) and false otherwise */
public boolean isSetCanRetry() {
return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CANRETRY_ISSET_ID);
}
public void setCanRetryIsSet(boolean value) {
__isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CANRETRY_ISSET_ID, value);
}
public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
switch (field) {
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((java.lang.String)value);
}
break;
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((java.lang.String)value);
}
break;
case CAN_RETRY:
if (value == null) {
unsetCanRetry();
} else {
setCanRetry((java.lang.Boolean)value);
}
break;
}
}
@ -162,8 +209,11 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
@org.apache.thrift.annotation.Nullable
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case MESSAGE:
return getMessage();
case MESSAGE:
return getMessage();
case CAN_RETRY:
return isCanRetry();
}
throw new java.lang.IllegalStateException();
@ -176,16 +226,16 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
}
switch (field) {
case MESSAGE:
return isSetMessage();
case MESSAGE:
return isSetMessage();
case CAN_RETRY:
return isSetCanRetry();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof IOError)
return this.equals((IOError)that);
return false;
@ -206,6 +256,15 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
return false;
}
boolean this_present_canRetry = true;
boolean that_present_canRetry = true;
if (this_present_canRetry || that_present_canRetry) {
if (!(this_present_canRetry && that_present_canRetry))
return false;
if (this.canRetry != that.canRetry)
return false;
}
return true;
}
@ -217,6 +276,8 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
if (isSetMessage())
hashCode = hashCode * 8191 + message.hashCode();
hashCode = hashCode * 8191 + ((canRetry) ? 131071 : 524287);
return hashCode;
}
@ -228,7 +289,7 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
lastComparison = java.lang.Boolean.compare(isSetMessage(), other.isSetMessage());
if (lastComparison != 0) {
return lastComparison;
}
@ -238,6 +299,16 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
return lastComparison;
}
}
lastComparison = java.lang.Boolean.compare(isSetCanRetry(), other.isSetCanRetry());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetCanRetry()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.canRetry, other.canRetry);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@ -266,6 +337,10 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
sb.append(this.message);
}
first = false;
if (!first) sb.append(", ");
sb.append("canRetry:");
sb.append(this.canRetry);
first = false;
sb.append(")");
return sb.toString();
}
@ -285,6 +360,8 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
@ -305,7 +382,7 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
@ -313,7 +390,15 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.message = iprot.readString();
struct.setMessageIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // CAN_RETRY
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.canRetry = iprot.readBool();
struct.setCanRetryIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@ -337,6 +422,9 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
oprot.writeString(struct.message);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(CAN_RETRY_FIELD_DESC);
oprot.writeBool(struct.canRetry);
oprot.writeFieldEnd();
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@ -358,20 +446,30 @@ public class IOError extends org.apache.thrift.TException implements org.apache.
if (struct.isSetMessage()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetCanRetry()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetMessage()) {
oprot.writeString(struct.message);
}
if (struct.isSetCanRetry()) {
oprot.writeBool(struct.canRetry);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, IOError struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(1);
java.util.BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.message = iprot.readString();
struct.setMessageIsSet(true);
}
if (incoming.get(1)) {
struct.canRetry = iprot.readBool();
struct.setCanRetryIsSet(true);
}
}
}

View File

@ -175,6 +175,7 @@ public class ThriftHBaseServiceHandler extends HBaseServiceHandler implements TH
private TIOError getTIOError(IOException e) {
TIOError err = new TIOErrorWithCause(e);
err.setMessage(e.getMessage());
err.setCanRetry(!(e instanceof DoNotRetryIOException));
return err;
}

View File

@ -17,15 +17,18 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIOError");
private static final org.apache.thrift.protocol.TField MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("message", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField CAN_RETRY_FIELD_DESC = new org.apache.thrift.protocol.TField("canRetry", org.apache.thrift.protocol.TType.BOOL, (short)2);
private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new TIOErrorStandardSchemeFactory();
private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new TIOErrorTupleSchemeFactory();
public @org.apache.thrift.annotation.Nullable java.lang.String message; // optional
public boolean canRetry; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
MESSAGE((short)1, "message");
MESSAGE((short)1, "message"),
CAN_RETRY((short)2, "canRetry");
private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();
@ -43,6 +46,8 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
switch(fieldId) {
case 1: // MESSAGE
return MESSAGE;
case 2: // CAN_RETRY
return CAN_RETRY;
default:
return null;
}
@ -84,12 +89,16 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.MESSAGE};
private static final int __CANRETRY_ISSET_ID = 0;
private byte __isset_bitfield = 0;
private static final _Fields optionals[] = {_Fields.MESSAGE,_Fields.CAN_RETRY};
public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("message", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.CAN_RETRY, new org.apache.thrift.meta_data.FieldMetaData("canRetry", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TIOError.class, metaDataMap);
}
@ -101,9 +110,11 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
* Performs a deep copy on <i>other</i>.
*/
public TIOError(TIOError other) {
__isset_bitfield = other.__isset_bitfield;
if (other.isSetMessage()) {
this.message = other.message;
}
this.canRetry = other.canRetry;
}
public TIOError deepCopy() {
@ -113,6 +124,8 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
@Override
public void clear() {
this.message = null;
setCanRetryIsSet(false);
this.canRetry = false;
}
@org.apache.thrift.annotation.Nullable
@ -140,15 +153,46 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
}
}
public boolean isCanRetry() {
return this.canRetry;
}
public TIOError setCanRetry(boolean canRetry) {
this.canRetry = canRetry;
setCanRetryIsSet(true);
return this;
}
public void unsetCanRetry() {
__isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CANRETRY_ISSET_ID);
}
/** Returns true if field canRetry is set (has been assigned a value) and false otherwise */
public boolean isSetCanRetry() {
return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CANRETRY_ISSET_ID);
}
public void setCanRetryIsSet(boolean value) {
__isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CANRETRY_ISSET_ID, value);
}
public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
switch (field) {
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((java.lang.String)value);
}
break;
case MESSAGE:
if (value == null) {
unsetMessage();
} else {
setMessage((java.lang.String)value);
}
break;
case CAN_RETRY:
if (value == null) {
unsetCanRetry();
} else {
setCanRetry((java.lang.Boolean)value);
}
break;
}
}
@ -156,8 +200,11 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
@org.apache.thrift.annotation.Nullable
public java.lang.Object getFieldValue(_Fields field) {
switch (field) {
case MESSAGE:
return getMessage();
case MESSAGE:
return getMessage();
case CAN_RETRY:
return isCanRetry();
}
throw new java.lang.IllegalStateException();
@ -170,16 +217,16 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
}
switch (field) {
case MESSAGE:
return isSetMessage();
case MESSAGE:
return isSetMessage();
case CAN_RETRY:
return isSetCanRetry();
}
throw new java.lang.IllegalStateException();
}
@Override
public boolean equals(java.lang.Object that) {
if (that == null)
return false;
if (that instanceof TIOError)
return this.equals((TIOError)that);
return false;
@ -200,6 +247,15 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
return false;
}
boolean this_present_canRetry = true && this.isSetCanRetry();
boolean that_present_canRetry = true && that.isSetCanRetry();
if (this_present_canRetry || that_present_canRetry) {
if (!(this_present_canRetry && that_present_canRetry))
return false;
if (this.canRetry != that.canRetry)
return false;
}
return true;
}
@ -211,6 +267,10 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
if (isSetMessage())
hashCode = hashCode * 8191 + message.hashCode();
hashCode = hashCode * 8191 + ((isSetCanRetry()) ? 131071 : 524287);
if (isSetCanRetry())
hashCode = hashCode * 8191 + ((canRetry) ? 131071 : 524287);
return hashCode;
}
@ -222,7 +282,7 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
int lastComparison = 0;
lastComparison = java.lang.Boolean.valueOf(isSetMessage()).compareTo(other.isSetMessage());
lastComparison = java.lang.Boolean.compare(isSetMessage(), other.isSetMessage());
if (lastComparison != 0) {
return lastComparison;
}
@ -232,6 +292,16 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
return lastComparison;
}
}
lastComparison = java.lang.Boolean.compare(isSetCanRetry(), other.isSetCanRetry());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetCanRetry()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.canRetry, other.canRetry);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@ -262,6 +332,12 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
}
first = false;
}
if (isSetCanRetry()) {
if (!first) sb.append(", ");
sb.append("canRetry:");
sb.append(this.canRetry);
first = false;
}
sb.append(")");
return sb.toString();
}
@ -281,6 +357,8 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
@ -301,7 +379,7 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
@ -309,7 +387,15 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.message = iprot.readString();
struct.setMessageIsSet(true);
} else {
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // CAN_RETRY
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.canRetry = iprot.readBool();
struct.setCanRetryIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
@ -335,6 +421,11 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
oprot.writeFieldEnd();
}
}
if (struct.isSetCanRetry()) {
oprot.writeFieldBegin(CAN_RETRY_FIELD_DESC);
oprot.writeBool(struct.canRetry);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@ -356,20 +447,30 @@ public class TIOError extends org.apache.thrift.TException implements org.apache
if (struct.isSetMessage()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetCanRetry()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetMessage()) {
oprot.writeString(struct.message);
}
if (struct.isSetCanRetry()) {
oprot.writeBool(struct.canRetry);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TIOError struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
java.util.BitSet incoming = iprot.readBitSet(1);
java.util.BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.message = iprot.readString();
struct.setMessageIsSet(true);
}
if (incoming.get(1)) {
struct.canRetry = iprot.readBool();
struct.setCanRetryIsSet(true);
}
}
}

View File

@ -174,6 +174,7 @@ struct TAppend {
*/
exception IOError {
1:string message
2:bool canRetry
}
/**

View File

@ -511,6 +511,7 @@ struct TOnlineLogRecord {
*/
exception TIOError {
1: optional string message
2: optional bool canRetry
}
/**