mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
reftable: adapt writer_add_record() to propagate block_writer_add() errors
Previously, writer_add_record() would flush the current block and retry appending the record whenever block_writer_add() returned any nonzero error. This forced an assumption that every failure meant the block was full, even when errors such as memory allocation or I/O failures occurred. Update the writer_add_record() to inspect the error code returned by block_writer_add() and only flush and reinitialize the writer when the error is REFTABLE_ENTRY_TOO_BIG_ERROR. For any other error, immediately propagate it. Signed-off-by: Meet Soni <meetsoni3017@gmail.com> Acked-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
27571684dd
commit
9ce297239b
@@ -310,11 +310,12 @@ static int writer_add_record(struct reftable_writer *w,
|
|||||||
* done. Otherwise the block writer may have hit the block size limit
|
* done. Otherwise the block writer may have hit the block size limit
|
||||||
* and needs to be flushed.
|
* and needs to be flushed.
|
||||||
*/
|
*/
|
||||||
if (!block_writer_add(w->block_writer, rec)) {
|
err = block_writer_add(w->block_writer, rec);
|
||||||
err = 0;
|
if (err == 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (err != REFTABLE_ENTRY_TOO_BIG_ERROR)
|
||||||
|
goto done;
|
||||||
/*
|
/*
|
||||||
* The current block is full, so we need to flush and reinitialize the
|
* The current block is full, so we need to flush and reinitialize the
|
||||||
* writer to start writing the next block.
|
* writer to start writing the next block.
|
||||||
@@ -329,16 +330,10 @@ static int writer_add_record(struct reftable_writer *w,
|
|||||||
/*
|
/*
|
||||||
* Try to add the record to the writer again. If this still fails then
|
* Try to add the record to the writer again. If this still fails then
|
||||||
* the record does not fit into the block size.
|
* the record does not fit into the block size.
|
||||||
*
|
|
||||||
* TODO: it would be great to have `block_writer_add()` return proper
|
|
||||||
* error codes so that we don't have to second-guess the failure
|
|
||||||
* mode here.
|
|
||||||
*/
|
*/
|
||||||
err = block_writer_add(w->block_writer, rec);
|
err = block_writer_add(w->block_writer, rec);
|
||||||
if (err) {
|
if (err)
|
||||||
err = REFTABLE_ENTRY_TOO_BIG_ERROR;
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
Reference in New Issue
Block a user