private static void handleSetTabletEnablePersistentIndex(long backendId, Map<Long, TTablet> backendTablets) {
        List<Pair<Long, Boolean>> tabletToEnablePersistentIndex = Lists.newArrayList();

        TabletInvertedIndex invertedIndex = GlobalStateMgr.getCurrentState().getTabletInvertedIndex();
        for (TTablet backendTablet : backendTablets.values()) {
            for (TTabletInfo tabletInfo : backendTablet.tablet_infos) {
                if (!tabletInfo.isSetEnable_persistent_index()) {
                    continue;
                }
                long tabletId = tabletInfo.getTablet_id();
                boolean beEnablePersistentIndex = tabletInfo.enable_persistent_index;
                TabletMeta tabletMeta = invertedIndex.getTabletMeta(tabletId);
                long dbId = tabletMeta != null ? tabletMeta.getDbId() : TabletInvertedIndex.NOT_EXIST_VALUE;
                long tableId = tabletMeta != null ? tabletMeta.getTableId() : TabletInvertedIndex.NOT_EXIST_VALUE;

                Database db = GlobalStateMgr.getCurrentState().getDb(dbId);
                if (db == null) {
                    continue;
                }

                OlapTable olapTable = (OlapTable) db.getTable(tableId);
                if (olapTable == null) {
                    continue;
                }

                Locker locker = new Locker();
                locker.lockTablesWithIntensiveDbLock(db, Lists.newArrayList(olapTable.getId()), LockType.READ);
                try {
                    boolean feEnablePersistentIndex = olapTable.enablePersistentIndex();
                    if (beEnablePersistentIndex != feEnablePersistentIndex) {
                        tabletToEnablePersistentIndex.add(new Pair<>(tabletId, feEnablePersistentIndex));
                    }
                } finally {
                    locker.unLockTablesWithIntensiveDbLock(db, Lists.newArrayList(olapTable.getId()), LockType.READ);
                }
            }
        }

        if (!tabletToEnablePersistentIndex.isEmpty()) {
            LOG.info("find [{}] tablet(s) which need to be set with persistent index enabled",
                    tabletToEnablePersistentIndex.size());
            AgentBatchTask batchTask = new AgentBatchTask();
            TabletMetadataUpdateAgentTask task = TabletMetadataUpdateAgentTaskFactory
                    .createEnablePersistentIndexUpdateTask(backendId, tabletToEnablePersistentIndex);
            batchTask.addTask(task);
            if (FeConstants.runningUnitTest) {
                AgentTaskExecutor.submit(batchTask);
            }
        }
    }
@Test
    public void testHandleSetTabletEnablePersistentIndex() {
        Database db = GlobalStateMgr.getCurrentState().getDb("test");
        long dbId = db.getId();
        long backendId = 10001L;
        List<Long> tabletIds = GlobalStateMgr.getCurrentState().getTabletInvertedIndex().getTabletIdsByBackendId(10001);
        Assert.assertFalse(tabletIds.isEmpty());

        Map<Long, TTablet> backendTablets = new HashMap<Long, TTablet>();
        List<TTabletInfo> tabletInfos = Lists.newArrayList();
        TTablet tablet = new TTablet(tabletInfos);
        for (Long tabletId : tabletIds) {
            TTabletInfo tabletInfo = new TTabletInfo();
            tabletInfo.setTablet_id(tabletId);
            tabletInfo.setSchema_hash(60000);
            tabletInfo.setEnable_persistent_index(true);
            tablet.tablet_infos.add(tabletInfo);
        }
        backendTablets.put(backendId, tablet);

        ReportHandler handler = new ReportHandler();
        handler.testHandleSetTabletEnablePersistentIndex(backendId, backendTablets);
    }