public static String optimizeErrorMessage(String msg) {
        if (msg == null) {
            return null;
        }
        if (SERVER_ID_CONFLICT.matcher(msg).matches()) {
            // Optimize the error msg when server id conflict
            msg +=
                    "\nThe 'server-id' in the mysql cdc connector should be globally unique, but conflicts happen now.\n"
                            + "The server id conflict may happen in the following situations: \n"
                            + "1. The server id has been used by other mysql cdc table in the current job.\n"
                            + "2. The server id has been used by the mysql cdc table in other jobs.\n"
                            + "3. The server id has been used by other sync tools like canal, debezium and so on.\n";
        } else if (MISSING_BINLOG_POSITION_WHEN_BINLOG_EXPIRE.matcher(msg).matches()
                || MISSING_TRANSACTION_WHEN_BINLOG_EXPIRE.matcher(msg).matches()) {
            // Optimize the error msg when binlog is unavailable
            msg +=
                    "\nThe required binary logs are no longer available on the server. This may happen in following situations:\n"
                            + "1. The speed of CDC source reading is too slow to exceed the binlog expired period. You can consider increasing the binary log expiration period, you can also to check whether there is back pressure in the job and optimize your job.\n"
                            + "2. The job runs normally, but something happens in the database and lead to the binlog cleanup. You can try to check why this cleanup happens from MySQL side.";
        }
        return msg;
    }
@Test
    public void testOptimizeErrorMessageWhenMissingBinlogPositionInMaster() {
        assertEquals(
                "Cannot replicate because the master purged required binary logs. Replicate the missing transactions from elsewhere, or provision a new slave from backup. Consider increasing the master's binary log expiration period. The GTID set sent by the slave is 'b9d6f3df-79e7-11ed-9a81-0242ac110004:1-33', and the missing transactions are 'b9d6f3df-79e7-11ed-9a81-0242ac110004:34'"
                        + "\nThe required binary logs are no longer available on the server. This may happen in following situations:\n"
                        + "1. The speed of CDC source reading is too slow to exceed the binlog expired period. You can consider increasing the binary log expiration period, you can also to check whether there is back pressure in the job and optimize your job.\n"
                        + "2. The job runs normally, but something happens in the database and lead to the binlog cleanup. You can try to check why this cleanup happens from MySQL side.",
                ErrorMessageUtils.optimizeErrorMessage(
                        "Cannot replicate because the master purged required binary logs. Replicate the missing transactions from elsewhere, or provision a new slave from backup. Consider increasing the master's binary log expiration period. The GTID set sent by the slave is 'b9d6f3df-79e7-11ed-9a81-0242ac110004:1-33', and the missing transactions are 'b9d6f3df-79e7-11ed-9a81-0242ac110004:34'"));
    }