Thread (19 messages) 19 messages, 2 authors, 2025-03-19
STALE464d
Revisions (2)
  1. v4 current
  2. v5 [diff vs current]

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

From: Meet Soni <hidden>
Date: 2025-03-19 08:00:49
Subsystem: the rest · Maintainer: Linus Torvalds

    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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help