public void execute() throws Exception {
        forward();
        LOG.info("forwarding to master get result max journal id: {}", result.maxJournalId);
        ctx.getGlobalStateMgr().getJournalObservable().waitOn(result.maxJournalId, waitTimeoutMs);

        if (result.state != null) {
            MysqlStateType state = MysqlStateType.fromString(result.state);
            if (state != null) {
                ctx.getState().setStateType(state);
                if (result.isSetErrorMsg()) {
                    ctx.getState().setMsg(result.getErrorMsg());
                }
                if (state == MysqlStateType.EOF || state == MysqlStateType.OK) {
                    afterForward();
                }
            }
        }

        if (result.isSetResource_group_name()) {
            ctx.getAuditEventBuilder().setResourceGroup(result.getResource_group_name());
        }
        if (result.isSetAudit_statistics()) {
            TAuditStatistics tAuditStatistics = result.getAudit_statistics();
            if (ctx.getExecutor() != null) {
                ctx.getExecutor().setQueryStatistics(AuditStatisticsUtil.toProtobuf(tAuditStatistics));
            }
        }
    }
@Test
    public void testForwardTooManyTimes() {
        ConnectContext connectContext = new ConnectContext();
        connectContext.setForwardTimes(LeaderOpExecutor.MAX_FORWARD_TIMES);

        try {
            new LeaderOpExecutor(new OriginStatement("show frontends"), connectContext, RedirectStatus.FORWARD_NO_SYNC)
                    .execute();
        } catch (Exception e) {
            Assert.assertTrue(e instanceof ErrorReportException);
            Assert.assertEquals(ErrorCode.ERR_FORWARD_TOO_MANY_TIMES, ((ErrorReportException) e).getErrorCode());
            return;
        }
        Assert.fail("should throw ERR_FORWARD_TOO_MANY_TIMES exception");
    }