MyCATApache/Mycat-Server · error · IllegalArgumentException

columnValue: Please check if the format satisfied.

Error message

columnValue:{columnValue} Please check if the format satisfied.

What it means

LatestMonthPartion.calculate parses the last four characters of the sharding value as a day and the last two as an hour to compute the partition index. Any NumberFormatException (bad date format) is rethrown as IllegalArgumentException asking the caller to check the value's format — it expects a string ending in DDHH (2-digit day, 2-digit hour) after the prefix length.

Solutions

  1. Format the sharding key so the string ends with exactly 4 digits: 2-digit day of month (01-31) + 2-digit hour (00-23), matching valueLen.
  2. Validate/normalize timestamps in the application before insert/query (e.g. DateTimeFormatter 'ddHH' suffix).
  3. Verify rule.xml valueLen/splitOneDay configuration matches the actual column format.
  4. Trim or strip separators ('-', 'T', ':') from the partition key value.

Example fix

// before
String key = "2026-09-10 14:30"; // parse fails
// after
String key = "202609101430"; // or ensure last 4 chars are e.g. "1014"
String formatted = ts.format(DateTimeFormatter.ofPattern("MMddHH"));
Defensive patterns

Strategy: validation

Validate before calling

boolean isValidLatestMonthKey(String v, int valueLen) {
    if (v == null || v.length() < valueLen || v.length() != valueLen) return false;
    String suffix = v.substring(valueLen - 4);
    return suffix.matches("\\d{2}(0[0-9]|1[0-9]|2[0-3])") &&
           Integer.parseInt(suffix.substring(0, 2)) >= 1;
}

Type guard

Integer tryComputePartition(String v, int valueLen) {
    try {
        int day = Integer.parseInt(v.substring(valueLen - 4, valueLen - 2));
        int hour = Integer.parseInt(v.substring(valueLen - 2));
        return day; // valid parse
    } catch (Exception e) { return null; }
}

Try / catch

try {
    insert(row);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("Please check if the format")) {
        LOGGER.error("bad LatestMonthPartion key: {}", row.getKey());
    } else { throw e; }
}

Prevention

When it happens

Trigger: calculate(columnValue) with a value whose trailing substring(valueLen-4, valueLen-2) or substring(valueLen-2) is not an integer — e.g. '2023010112' with wrong length, '2023xx011x', empty or shorter-than-4 strings.

Common situations: Sending full 'yyyyMMddHHmm' timestamps instead of the expected prefix+DDHH layout; passing null/short values; time-zone formatting differences adding 'T' or milliseconds; misconfigured valueLen so slicing lands on the wrong characters.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/832aa237eef272e2. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/route/function/LatestMonthPartion.java:45

		if (hourSpan * 24 < 24) {
			throw new java.lang.IllegalArgumentException(
					"invalid splitOnDay param:"
							+ splitOneDay
							+ " should be an even number and less or equals than 24");
		}
	}

	@Override
	public Integer calculate(String columnValue)  {
		try {
			int valueLen = columnValue.length();
			int day = Integer.parseInt(columnValue.substring(valueLen - 4,
					valueLen - 2));
			int hour = Integer.parseInt(columnValue.substring(valueLen - 2));
			int dnIndex = (day - 1) * splitOneDay + hour / hourSpan;
			return dnIndex;
		}catch (NumberFormatException e){
			throw new IllegalArgumentException(new StringBuilder().append("columnValue:").append(columnValue).append(" Please check if the format satisfied.").toString(),e);
		}
	}

	public Integer[] calculateRange(String beginValue, String endValue)  {
		return calculateSequenceRange(this,beginValue, endValue);
	}

}

View on GitHub (pinned to 65f8d8beb7)