@Override
    public void updateProgress(TReportExecStatusParams params) {
        writeLock();
        try {
            super.updateProgress(params);
            if (!loadingStatus.getLoadStatistic().getLoadFinish()) {
                if (this.loadType == TLoadJobType.INSERT_QUERY) {
                    if (loadingStatus.getLoadStatistic().totalFileSizeB != 0) {
                        // progress of file scan
                        progress = (int) ((double) loadingStatus.getLoadStatistic().sourceScanBytes() /
                                loadingStatus.getLoadStatistic().totalFileSize() * 100);
                    } else {
                        // progress of table scan. Slightly smaller than actual
                        progress = (int) ((double) loadingStatus.getLoadStatistic().totalSourceLoadRows()
                                / (estimateScanRow + 1) * 100);
                    }
                } else {
                    progress = (int) ((double) loadingStatus.getLoadStatistic().totalSinkLoadRows() 
                        / (estimateScanRow + 1) * 100);
                }

                if (progress >= 100) {
                    progress = 99;
                }
            }
        } finally {
            writeUnlock();
        }
    }
@Test
    public void testUpdateProgress(@Mocked GlobalStateMgr globalStateMgr,
                                   @Injectable Database database,
                                   @Injectable Table table) throws MetaNotFoundException {
        new Expectations() {
            {
                globalStateMgr.getDb(anyLong);
                result = database;
                database.getTable(anyLong);
                result = table;
                table.getName();
                result = "some_table";
            }
        };

        {
            InsertLoadJob loadJob = new InsertLoadJob("label", 1L,
                    1L, 1000, "", "", null);
            TUniqueId loadId = new TUniqueId(1, 2);

            TUniqueId fragmentId = new TUniqueId(3, 4);
            Set<TUniqueId> fragmentIds = new HashSet<>();
            fragmentIds.add(fragmentId);

            List<Long> backendIds = new ArrayList<>();
            backendIds.add(10001L);

            loadJob.initLoadProgress(loadId, fragmentIds, backendIds);
            loadJob.setEstimateScanRow(100);
            loadJob.setLoadFileInfo(0, 0);

            TReportExecStatusParams params = new TReportExecStatusParams();
            params.setSource_load_rows(40);
            params.setQuery_id(loadId);
            params.setFragment_instance_id(fragmentId);

            loadJob.updateProgress(params);
            Assert.assertEquals(39, loadJob.getProgress());

            Assert.assertTrue(loadJob.getTabletCommitInfos().isEmpty());
            Assert.assertTrue(loadJob.getTabletFailInfos().isEmpty());
        }

        {
            InsertLoadJob loadJob = new InsertLoadJob("label", 1L,
                    1L, 1000, "", "", null);
            TUniqueId loadId = new TUniqueId(1, 2);

            TUniqueId fragmentId = new TUniqueId(3, 4);
            Set<TUniqueId> fragmentIds = new HashSet<>();
            fragmentIds.add(fragmentId);

            List<Long> backendIds = new ArrayList<>();
            backendIds.add(10001L);

            loadJob.initLoadProgress(loadId, fragmentIds, backendIds);
            loadJob.setEstimateScanRow(0);
            loadJob.setLoadFileInfo(10, 100);

            TReportExecStatusParams params = new TReportExecStatusParams();
            params.setQuery_id(loadId);
            params.setFragment_instance_id(fragmentId);
            params.setSource_scan_bytes(80);

            loadJob.updateProgress(params);
            Assert.assertEquals(80, loadJob.getProgress());

            Assert.assertTrue(loadJob.getTabletCommitInfos().isEmpty());
            Assert.assertTrue(loadJob.getTabletFailInfos().isEmpty());
        }
    }