Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/main/java/com/alipay/oceanbase/hbase/OHTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.alipay.oceanbase.rpc.mutation.result.BatchOperationResult;
import com.alipay.oceanbase.rpc.mutation.result.MutationResult;
import com.alipay.oceanbase.rpc.protocol.payload.ObPayload;
import com.alipay.oceanbase.rpc.protocol.payload.ResultCodes;
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObObj;
import com.alipay.oceanbase.rpc.protocol.payload.impl.ObRowKey;
import com.alipay.oceanbase.rpc.protocol.payload.impl.execute.*;
Expand Down Expand Up @@ -1429,7 +1430,13 @@ public Result increment(Increment increment) throws IOException {
return new Result(keyValues);
} catch (Exception e) {
logger.error(LCD.convert("01-00007"), tableNameString, e);
throw new IOException("increment table " + tableNameString + " error.", e);
if (e instanceof ObTableException &&
((ObTableException) e).getErrorCode() == ResultCodes.OB_KV_HBASE_INCR_FIELD_IS_NOT_LONG.errorCode) {
String errMsg = OHBaseFuncUtils.generateIncrFieldErrMsg(e.getMessage());
throw new DoNotRetryIOException(errMsg, e);
} else {
throw new IOException("increment table " + tableNameString + " error.", e);
}
}
}

Expand Down Expand Up @@ -1473,7 +1480,13 @@ public long incrementColumnValue(byte[] row, byte[] family, byte[] qualifier, lo
return Bytes.toLong((byte[]) queryResult.getPropertiesRows().get(0).get(3).getValue());
} catch (Exception e) {
logger.error(LCD.convert("01-00007"), tableNameString, e);
throw new IOException("increment table " + tableNameString + " error.", e);
if (e instanceof ObTableException
&& ((ObTableException) e).getErrorCode() == ResultCodes.OB_KV_HBASE_INCR_FIELD_IS_NOT_LONG.errorCode) {
String errMsg = OHBaseFuncUtils.generateIncrFieldErrMsg(e.getMessage());
throw new DoNotRetryIOException(errMsg, e);
} else {
throw new IOException("increment table " + tableNameString + " error.", e);
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/alipay/oceanbase/hbase/util/OHBaseFuncUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import java.util.Arrays;

import static java.lang.String.format;

@InterfaceAudience.Private
public class OHBaseFuncUtils {
public static byte[][] extractFamilyFromQualifier(byte[] qualifier) throws Exception {
Expand All @@ -38,4 +40,13 @@ public static byte[][] extractFamilyFromQualifier(byte[] qualifier) throws Excep
byte[] newQualifier = Arrays.copyOfRange(qualifier, familyLen + 1, qualifier.length);
return new byte[][] { family, newQualifier };
}

public static String generateIncrFieldErrMsg(String errMsg) {
// [-10516][OB_KV_HBASE_INCR_FIELD_IS_NOT_LONG][When invoking the Increment interface, only HBase cells with a length of 8 can be converted to int64_t. the current length of the HBase cell is '4'.][ip:port][trace_id]
int start = errMsg.indexOf('\'');
int stop = errMsg.lastIndexOf('\'');
String errByte = errMsg.substring(start + 1, stop);
errMsg = format("Field is not a long, it's %s bytes wide", errByte);
return errMsg;
}
}