Skip to content

Commit 7fa52fd

Browse files
pks-tgitster
authored andcommitted
reftable/stack: fsync "tables.list" during compaction
In 1df18a1 (reftable: honor core.fsync, 2024-01-23), we have added code to fsync both newly written reftables as well as "tables.list" to disk. But there are two code paths where "tables.list" is being written: - When appending a new table due to a normal ref update. - When compacting a range of tables during compaction. We have only addressed the former code path, but do not yet sync the new "tables.list" file in the latter. Fix this omission. Note that we are not yet adding any tests. These tests will be added once the "reftable" backend has been upstreamed. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1df18a1 commit 7fa52fd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

reftable/stack.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,14 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
10181018
unlink(new_table_path.buf);
10191019
goto done;
10201020
}
1021+
1022+
err = fsync_component(FSYNC_COMPONENT_REFERENCE, lock_file_fd);
1023+
if (err < 0) {
1024+
err = REFTABLE_IO_ERROR;
1025+
unlink(new_table_path.buf);
1026+
goto done;
1027+
}
1028+
10211029
err = close(lock_file_fd);
10221030
lock_file_fd = -1;
10231031
if (err < 0) {

0 commit comments

Comments
 (0)