diff --git a/table/block_based/block_based_table_builder.cc b/table/block_based/block_based_table_builder.cc index cf1ea5db6..fb25a7ff9 100644 --- a/table/block_based/block_based_table_builder.cc +++ b/table/block_based/block_based_table_builder.cc @@ -1613,13 +1613,21 @@ void BlockBasedTableBuilder::WriteIndexBlock( } // If there are more index partitions, finish them and write them out if (index_builder_status.IsIncomplete()) { - Status s = Status::Incomplete(); - while (ok() && s.IsIncomplete()) { - s = rep_->index_builder->Finish(&index_blocks, *index_block_handle); - if (!s.ok() && !s.IsIncomplete()) { + bool index_building_finished = false; + while (ok() && !index_building_finished) { + Status s = + rep_->index_builder->Finish(&index_blocks, *index_block_handle); + if (s.ok()) { + index_building_finished = true; + } else if (s.IsIncomplete()) { + // More partitioned index after this one + assert(!index_building_finished); + } else { + // Error rep_->SetStatus(s); return; } + if (rep_->table_options.enable_index_compression) { WriteBlock(index_blocks.index_block_contents, index_block_handle, BlockType::kIndex);