1
0
mirror of https://github.com/git/git.git synced 2024-09-23 08:21:16 +02:00
git/reftable
Patrick Steinhardt e7485601ca reftable/writer: fix writing multi-level indices
When finishing a section we will potentially write an index that makes
it more efficient to look up relevant blocks. The index records written
will encode, for each block of the indexed section, what the offset of
that block is as well as the last key of that block. Thus, the reader
would iterate through the index records to find the first key larger or
equal to the wanted key and then use the encoded offset to look up the
desired block.

When there are a lot of blocks to index though we may end up writing
multiple index blocks, too. To not require a linear search across all
index blocks we instead end up writing a multi-level index. Instead of
referring to the block we are after, an index record may point to
another index block. The reader will then access the highest-level index
and follow down the chain of index blocks until it hits the sought-after
block.

It has been observed though that it is impossible to seek ref records of
the last ref block when using a multi-level index. While the multi-level
index exists and looks fine for most of the part, the highest-level
index was missing an index record pointing to the last block of the next
index. Thus, every additional level made more refs become unseekable at
the end of the ref section.

The root cause is that we are not flushing the last block of the current
level once done writing the level. Consequently, it wasn't recorded in
the blocks that need to be indexed by the next-higher level and thus we
forgot about it.

Fix this bug by flushing blocks after we have written all index records.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-02-01 11:11:32 -08:00
..
basics_test.c
basics.c
basics.h
block_test.c
block.c
block.h
blocksource.c
blocksource.h
constants.h
dump.c
error.c
generic.c
generic.h
iter.c
iter.h
LICENSE
merged_test.c reftable: honor core.fsync 2024-01-23 13:45:27 -08:00
merged.c
merged.h
pq_test.c
pq.c
pq.h
publicbasics.c
reader.c reftable/reader: be more careful about errors in indexed seeks 2024-02-01 11:11:32 -08:00
reader.h
readwrite_test.c reftable/writer: fix writing multi-level indices 2024-02-01 11:11:32 -08:00
record_test.c
record.c
record.h
refname_test.c reftable: honor core.fsync 2024-01-23 13:45:27 -08:00
refname.c
refname.h
reftable-blocksource.h
reftable-error.h
reftable-generic.h
reftable-iterator.h
reftable-malloc.h
reftable-merged.h
reftable-reader.h
reftable-record.h
reftable-stack.h
reftable-tests.h
reftable-writer.h reftable: honor core.fsync 2024-01-23 13:45:27 -08:00
stack_test.c
stack.c reftable/stack: fsync "tables.list" during compaction 2024-01-30 11:56:15 -08:00
stack.h
system.h
test_framework.c reftable: honor core.fsync 2024-01-23 13:45:27 -08:00
test_framework.h reftable: honor core.fsync 2024-01-23 13:45:27 -08:00
tree_test.c
tree.c
tree.h
writer.c reftable/writer: fix writing multi-level indices 2024-02-01 11:11:32 -08:00
writer.h reftable: honor core.fsync 2024-01-23 13:45:27 -08:00