**Describe the bug**
https://github.com/ClickHouse/ClickHouse/pull/18899#issuecomment-757571194

{
    
    
    
    if (compute_granularity)
    {
        size_t index_granularity_for_block = computeIndexGranularity(block);
        if (rows_written_in_last_mark > 0)
        {
            size_t rows_left_in_last_mark = index_granularity.getMarkRows(getCurrentMark()) - rows_written_in_last_mark;
            
            
            
            if (rows_left_in_last_mark > index_granularity_for_block)
            {
                
                
                if (rows_written_in_last_mark >= index_granularity_for_block)
                    adjustLastMarkIfNeedAndFlushToDisk(rows_written_in_last_mark);
                else 
                    adjustLastMarkIfNeedAndFlushToDisk(index_granularity_for_block - rows_written_in_last_mark);
            }
        }
        fillIndexGranularity(index_granularity_for_block, block.rows());