private Replica findRelatedReplica(OlapTable olapTable, PhysicalPartition physicalPartition,
                                       long backendId, long tabletId, long indexId)
            throws MetaNotFoundException {
        // both normal index and rolling up index are in inverted index
        // this means the index is dropped during load
        if (indexId == TabletInvertedIndex.NOT_EXIST_VALUE) {
            LOG.warn("tablet[{}] may be dropped. push index[{}]", tabletId, indexId);
            return null;
        }
        MaterializedIndex index = physicalPartition.getIndex(indexId);
        if (index == null) {
            if (olapTable.getState() == OlapTableState.ROLLUP) {
                // this happens when:
                // a rollup job is finish and a delete job is the next first job (no load job before)
                // and delete task is first send to base tablet, so it will return 2 tablets info.
                // the second tablet is rollup tablet, and it is no longer exist in alterJobs queue.
                // just ignore the rollup tablet info. it will be handled in rollup tablet delete task report.

                // add log to observe
                LOG.warn("Cannot find table[{}].", olapTable.getId());
                return null;
            }
            throw new MetaNotFoundException("Could not find rollup index.");
        }

        Tablet tablet = index.getTablet(tabletId);
        if (tablet instanceof LakeTablet) {
            return new Replica(tabletId, backendId, -1, NORMAL);
        } else {
            if (tablet == null) {
                LOG.warn("could not find tablet {} in rollup index {} ", tabletId, indexId);
                return null;
            }
            Replica replica = ((LocalTablet) tablet).getReplicaByBackendId(backendId);
            if (replica == null) {
                LOG.warn("could not find replica with backend {} in tablet {} in rollup index {} ",
                        backendId, tabletId, indexId);
            }
            return replica;
        }
    }
@Test
    public void testFindRelatedReplica(@Mocked OlapTable olapTable, @Mocked LakeTable lakeTable,
                                       @Mocked Partition partition, @Mocked MaterializedIndex index
                                       ) throws Exception {

        // olap table
        new Expectations() {
            {
                partition.getIndex(indexId);
                result = index;
                index.getTablet(tabletId);
                result = new LocalTablet(tabletId);
            }
        };
        
        Assert.assertNull(Deencapsulation.invoke(leader, "findRelatedReplica",
                olapTable, partition, backendId, tabletId, indexId));
        // lake table
        new MockUp<LakeTablet>() {
            @Mock
            public Set<Long> getBackendIds() {
                return Sets.newHashSet();
            }
        };

        new Expectations() {
            {
                partition.getIndex(indexId);
                result = index;
                index.getTablet(tabletId);
                result = new LakeTablet(tabletId);
            }
        };

        Assert.assertEquals(new Replica(tabletId, backendId, -1, NORMAL), Deencapsulation.invoke(leader, "findRelatedReplica",
                olapTable, partition, backendId, tabletId, indexId));
    }