Commit c8aeaf3a authored by Jeff Davis's avatar Jeff Davis

Change LogicalTapeSetBlocks() to use nBlocksWritten.

Previously, it was based on nBlocksAllocated to account for tapes with
open write buffers that may not have made it to the BufFile yet.

That was unnecessary, because callers do not need to get the number of
blocks while a tape has an open write buffer; and it also conflicted
with the preallocation logic added for HashAgg.

Reviewed-by: Peter Geoghegan
Discussion: https://postgr.es/m/ce5af05900fdbd0e9185747825a7423c48501964.camel@j-davis.com
Backpatch-through: 13
parent 3bd35d4f
...@@ -2704,8 +2704,8 @@ agg_refill_hash_table(AggState *aggstate) ...@@ -2704,8 +2704,8 @@ agg_refill_hash_table(AggState *aggstate)
if (spill_initialized) if (spill_initialized)
{ {
hash_agg_update_metrics(aggstate, true, spill.npartitions);
hashagg_spill_finish(aggstate, &spill, batch->setno); hashagg_spill_finish(aggstate, &spill, batch->setno);
hash_agg_update_metrics(aggstate, true, spill.npartitions);
} }
else else
hash_agg_update_metrics(aggstate, true, 0); hash_agg_update_metrics(aggstate, true, 0);
......
...@@ -1264,9 +1264,19 @@ LogicalTapeTell(LogicalTapeSet *lts, int tapenum, ...@@ -1264,9 +1264,19 @@ LogicalTapeTell(LogicalTapeSet *lts, int tapenum,
/* /*
* Obtain total disk space currently used by a LogicalTapeSet, in blocks. * Obtain total disk space currently used by a LogicalTapeSet, in blocks.
*
* This should not be called while there are open write buffers; otherwise it
* may not account for buffered data.
*/ */
long long
LogicalTapeSetBlocks(LogicalTapeSet *lts) LogicalTapeSetBlocks(LogicalTapeSet *lts)
{ {
return lts->nBlocksAllocated - lts->nHoleBlocks; #ifdef USE_ASSERT_CHECKING
for (int i = 0; i < lts->nTapes; i++)
{
LogicalTape *lt = &lts->tapes[i];
Assert(!lt->writing || lt->buffer == NULL);
}
#endif
return lts->nBlocksWritten - lts->nHoleBlocks;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment