git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 3/3] reftable: adapt write_object_record() to propagate block_writer_add() errors

From
Meet Soni <meetsoni3017@gmail.com>
Date
Mar 19, 2025, 07:59 UTC
Message-ID
<20250319075943.28904-4-meetsoni3017@gmail.com>
In-Reply-To
<20250319075943.28904-1-meetsoni3017@gmail.com>
    Previously, write_object_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 write_object_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.
    All call sites now handle various error codes returned by
    block_writer_add().
Signed-off-by: Meet Soni <meetsoni3017@gmail.com>
---
 reftable/writer.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff --git a/reftable/writer.c b/reftable/writer.c
index 94c97b7ac0..3fdfa4d34b 100644
--- a/reftable/writer.c
+++ b/reftable/writer.c
@@ -620,10 +620,22 @@ static void write_object_record(void *void_arg, void *key)
 	if (arg->err < 0)
 		goto done;
 
+	/*
+	 * Try to add the record to the writer. If this succeeds then we're
+	 * done. Otherwise the block writer may have hit the block size limit
+	 * and needs to be flushed.
+	 */
 	arg->err = block_writer_add(arg->w->block_writer, &rec);
 	if (arg->err == 0)
 		goto done;
 
+	if (arg->err != REFTABLE_ENTRY_TOO_BIG_ERROR)
+		goto done;
+
+	/*
+	 * The current block is full, so we need to flush and reinitialize the
+	 * writer to start writing the next block.
+	 */
 	arg->err = writer_flush_block(arg->w);
 	if (arg->err < 0)
 		goto done;
-- 
2.34.1
Previous: Meet SoniNext: Meet Soni
Message 15 of 20 in “reftable: return proper error code from block_writer_add()”
  1. reftable: return proper error code from block_writer_add()Meet Soni, Mar 6, 2025
  2. Patrick SteinhardtMar 6, 2025
  3. Junio C HamanoMar 6, 2025
  4. reftable: return proper error code from block_writer_add()Meet Soni, Mar 8, 2025
  5. Patrick SteinhardtMar 12, 2025
  6. 0/2 reftable: return proper error codes from block_writer_addMeet Soni, Mar 12, 2025
  7. 1/2 reftable: propagate specific error codes in block_writer_add()Meet Soni, Mar 12, 2025
  8. 2/2 reftable: adapt writer code to propagate block_writer_add() errorsMeet Soni, Mar 12, 2025
  9. Patrick SteinhardtMar 12, 2025
  10. Meet SoniMar 13, 2025
  11. Patrick SteinhardtMar 19, 2025
  12. 0/3 reftable: return proper error codes from block_writer_addMeet Soni, Mar 19, 2025
  13. 1/3 reftable: propagate specific error codes in block_writer_add()Meet Soni, Mar 19, 2025
  14. 2/3 reftable: adapt writer_add_record() to propagate block_writer_add() errorsMeet Soni, Mar 19, 2025
  15. 3/3 reftable: adapt write_object_record() to propagate block_writer_add() errorsMeet Soni, Mar 19, 2025
  16. 0/3 reftable: return proper error codes from block_writer_addMeet Soni, Mar 19, 2025
  17. 1/3 reftable: propagate specific error codes in block_writer_add()Meet Soni, Mar 19, 2025
  18. 2/3 reftable: adapt writer_add_record() to propagate block_writer_add() errorsMeet Soni, Mar 19, 2025
  19. 3/3 reftable: adapt write_object_record() to propagate block_writer_add() errorsMeet Soni, Mar 19, 2025
  20. Patrick SteinhardtMar 19, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.