public static synchronized ShowResultSet process(List<AlterClause> alterClauses, Database db,
                                                     OlapTable olapTable) throws UserException {
        Preconditions.checkArgument(alterClauses.size() == 1);
        AlterClause alterClause = alterClauses.get(0);
        Preconditions.checkState(alterClause instanceof CompactionClause);

        CompactionClause compactionClause = (CompactionClause) alterClause;
        if (RunMode.isSharedDataMode()) {
            Locker locker = new Locker();
            locker.lockTablesWithIntensiveDbLock(db, Lists.newArrayList(olapTable.getId()), LockType.READ);
            try {
                List<Partition> allPartitions = findAllPartitions(olapTable, compactionClause);
                for (Partition partition : allPartitions) {
                    for (PhysicalPartition physicalPartition : partition.getSubPartitions()) {
                        PartitionIdentifier partitionIdentifier =
                                new PartitionIdentifier(db.getId(), olapTable.getId(), physicalPartition.getId());
                        CompactionMgr compactionManager = GlobalStateMgr.getCurrentState().getCompactionMgr();
                        compactionManager.triggerManualCompaction(partitionIdentifier);
                    }
                }
            } finally {
                locker.unLockTablesWithIntensiveDbLock(db, Lists.newArrayList(olapTable.getId()), LockType.READ);
            }
        } else {
            ArrayListMultimap<Long, Long> backendToTablets = ArrayListMultimap.create();
            AgentBatchTask batchTask = new AgentBatchTask();

            Locker locker = new Locker();
            locker.lockTablesWithIntensiveDbLock(db, Lists.newArrayList(olapTable.getId()), LockType.READ);
            try {
                List<Partition> allPartitions = findAllPartitions(olapTable, compactionClause);
                for (Partition partition : allPartitions) {
                    for (PhysicalPartition physicalPartition : partition.getSubPartitions()) {
                        for (MaterializedIndex index : physicalPartition.getMaterializedIndices(
                                MaterializedIndex.IndexExtState.VISIBLE)) {
                            for (Tablet tablet : index.getTablets()) {
                                for (Long backendId : ((LocalTablet) tablet).getBackendIds()) {
                                    backendToTablets.put(backendId, tablet.getId());
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                throw new UserException(e.getMessage());
            } finally {
                locker.unLockTablesWithIntensiveDbLock(db, Lists.newArrayList(olapTable.getId()), LockType.READ);
            }

            for (Long backendId : backendToTablets.keySet()) {
                CompactionTask task = new CompactionTask(null, backendId,
                        db.getId(),
                        olapTable.getId(),
                        backendToTablets.get(backendId),
                        ((CompactionClause) alterClause).isBaseCompaction()
                );

                // add task to send
                batchTask.addTask(task);
            }
            if (batchTask.getTaskNum() > 0) {
                for (AgentTask task : batchTask.getAllTasks()) {
                    AgentTaskQueue.addTask(task);
                }
                AgentTaskExecutor.submit(batchTask);
                LOG.debug("tablet[{}] send compaction task. num: {}", batchTask.getTaskNum());
            }
        }
        return null;
    }
@Test(expected = IllegalStateException.class)
    public void testProcessNonCompactionClause() {
        AlterClause nonCompactionClause = mock(AlterClause.class);
        List<AlterClause> alterList = Collections.singletonList((nonCompactionClause));
        try {
            compactionHandler.process(alterList, db, olapTable);
        } catch (UserException e) {
            Assert.fail("process should not throw user exceptions here");
        }
    }