DBZ-4371 Add hint on how to log problematic values

This commit is contained in:
Chris Cranford 2022-01-13 00:46:03 -05:00 committed by Jiri Pechanec
parent 0721ff991c
commit 4f5f72500c
2 changed files with 13 additions and 7 deletions

View File

@ -46,7 +46,8 @@ else if (b.length() == 0) {
// if micro_seconds is 0, length is 8; otherwise length is 12
if (b.length() != NativeConstants.BIN_LEN_TIME_NO_FRAC && b.length() != NativeConstants.BIN_LEN_TIME_WITH_MICROS) {
logInvalidValue(rs, columnIndex, b);
throw new RuntimeException(String.format("Invalid length when read MySQL TIME value. BIN_LEN_TIME is %d", b.length()));
throw new RuntimeException(String.format("Invalid length when read MySQL TIME value. BIN_LEN_TIME is %d. " +
"Enable TRACE logging to log the problematic column and its value.", b.length()));
}
final byte[] bytes = b.getBytes(1, (int) (b.length()));
@ -72,7 +73,8 @@ protected Object readDateField(ResultSet rs, int columnIndex, Column column, Tab
// length is 4
if (b.length() != NativeConstants.BIN_LEN_DATE) {
logInvalidValue(rs, columnIndex, b);
throw new RuntimeException(String.format("Invalid length when read MySQL DATE value. BIN_LEN_DATE is %d", b.length()));
throw new RuntimeException(String.format("Invalid length when read MySQL DATE value. BIN_LEN_DATE is %d. " +
"Enable TRACE logging to log the problematic column and its value.", b.length()));
}
final byte[] bytes = b.getBytes(1L, (int) b.length());
@ -93,7 +95,6 @@ protected Object readTimestampField(ResultSet rs, int columnIndex, Column column
return null; // Don't continue parsing timestamp field if it is null
}
else if (b.length() == 0) {
logInvalidValue(rs, columnIndex, b);
LOGGER.warn("Encountered a zero length blob for column index {}", columnIndex);
return null;
}
@ -101,7 +102,9 @@ else if (b.length() == 0) {
// if hour, minutes, seconds and micro_seconds are all 0, length is 4; if micro_seconds is 0, length is 7; otherwise length is 11
if (b.length() != NativeConstants.BIN_LEN_DATE && b.length() != NativeConstants.BIN_LEN_TIMESTAMP_NO_FRAC
&& b.length() != NativeConstants.BIN_LEN_TIMESTAMP_WITH_MICROS) {
throw new RuntimeException(String.format("Invalid length when read MySQL DATETIME value. BIN_LEN_DATETIME is %d", b.length()));
logInvalidValue(rs, columnIndex, b);
throw new RuntimeException(String.format("Invalid length when read MySQL DATETIME value. BIN_LEN_DATETIME is %d. " +
"Enable TRACE logging to log the problematic column and its value.", b.length()));
}
final byte[] bytes = b.getBytes(1, (int) (b.length()));

View File

@ -47,7 +47,8 @@ else if (b.length() == 0) {
}
catch (UnsupportedEncodingException e) {
logInvalidValue(rs, columnIndex, b);
logger.error("Could not read MySQL TIME value as UTF-8");
logger.error("Could not read MySQL TIME value as UTF-8. " +
"Enable TRACE logging to log the problematic column and its value.");
throw new RuntimeException(e);
}
}
@ -68,7 +69,8 @@ protected Object readDateField(ResultSet rs, int columnIndex, Column column, Tab
}
catch (UnsupportedEncodingException e) {
logInvalidValue(rs, columnIndex, b);
logger.error("Could not read MySQL DATE value as UTF-8");
logger.error("Could not read MySQL DATE value as UTF-8. " +
"Enable TRACE logging to log the problematic column and its value.");
throw new RuntimeException(e);
}
}
@ -94,7 +96,8 @@ else if (b.length() == 0) {
}
catch (UnsupportedEncodingException e) {
logInvalidValue(rs, columnIndex, b);
logger.error("Could not read MySQL DATETIME value as UTF-8");
logger.error("Could not read MySQL DATETIME value as UTF-8. " +
"Enable TRACE logging to log the problematic column and its value.");
throw new RuntimeException(e);
}
}