git/reftable
Patrick Steinhardt 8e27ee9220 reftable/stack: don't perform auto-compaction with less than two tables
In order to compact tables we need at least two tables. Bail out early
from `reftable_stack_auto_compact()` in case we have less than two
tables.

In the original, `stack_table_sizes_for_compaction()` yields an array
that has the same length as the number of tables. This array is then
passed on to `suggest_compaction_segment()`, which returns an empty
segment in case we have less than two tables. The segment is then passed
to `segment_size()`, which will return `0` because both start and end of
the segment are `0`. And because we only call `stack_compact_range()` in
case we have a positive segment size we don't perform auto-compaction at
all. Consequently, this change does not result in a user-visible change
in behaviour when called with a single table.

But when called with no tables this protects us against a potential
out-of-memory error: `stack_table_sizes_for_compaction()` would try to
allocate a zero-byte object when there aren't any tables, and that may
lead to a `NULL` pointer on some platforms like NonStop which causes us
to bail out with an out-of-memory error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2024-12-22 00:58:23 -08:00
..
LICENSE
basics.c reftable/basics: fix segfault when growing `names` array fails 2024-10-04 07:59:31 -07:00
basics.h reftable/basics: ban standard allocator functions 2024-10-02 07:53:56 -07:00
block.c reftable: introduce `REFTABLE_FREE_AND_NULL()` 2024-10-02 07:53:56 -07:00
block.h reftable/block: handle allocation failures 2024-10-02 07:53:55 -07:00
blocksource.c reftable/blocksource: handle allocation failures 2024-10-02 07:53:54 -07:00
blocksource.h reftable/blocksource: drop malloc block source 2024-08-23 08:04:46 -07:00
constants.h reftable: make the compaction factor configurable 2024-05-13 17:02:39 -07:00
error.c reftable/error: introduce out-of-memory error code 2024-10-02 07:53:50 -07:00
iter.c reftable: introduce `REFTABLE_FREE_AND_NULL()` 2024-10-02 07:53:56 -07:00
iter.h reftable/iter: handle allocation failures when creating indexed table iter 2024-10-02 07:53:54 -07:00
merged.c reftable: handle trivial allocation failures 2024-10-02 07:53:55 -07:00
merged.h reftable/merged: handle allocation failures in `merged_table_init_iter()` 2024-10-02 07:53:53 -07:00
pq.c reftable: introduce `REFTABLE_FREE_AND_NULL()` 2024-10-02 07:53:56 -07:00
pq.h reftable/pq: handle allocation failures when adding entries 2024-10-02 07:53:55 -07:00
reader.c reftable: introduce `REFTABLE_FREE_AND_NULL()` 2024-10-02 07:53:56 -07:00
reader.h reftable/reader: handle allocation failures in `reader_init_iter()` 2024-10-02 07:53:53 -07:00
record.c reftable: introduce `REFTABLE_FREE_AND_NULL()` 2024-10-02 07:53:56 -07:00
record.h reftable/record: handle allocation failures on copy 2024-10-02 07:53:52 -07:00
reftable-basics.h reftable/basics: merge "publicbasics" into "basics" 2024-10-02 07:53:51 -07:00
reftable-blocksource.h
reftable-error.h reftable/error: introduce out-of-memory error code 2024-10-02 07:53:50 -07:00
reftable-iterator.h reftable/generic: adapt interface to allow reuse of iterators 2024-05-13 17:04:18 -07:00
reftable-merged.h reftable/merged: handle allocation failures in `merged_table_init_iter()` 2024-10-02 07:53:53 -07:00
reftable-reader.h reftable/reader: handle allocation failures in `reader_init_iter()` 2024-10-02 07:53:53 -07:00
reftable-record.h t/helper: inline printing of reftable records 2024-08-22 07:59:47 -07:00
reftable-stack.h reftable/merged: handle allocation failures in `merged_table_init_iter()` 2024-10-02 07:53:53 -07:00
reftable-writer.h reftable/writer: handle allocation failures in `reftable_new_writer()` 2024-10-02 07:53:52 -07:00
stack.c reftable/stack: don't perform auto-compaction with less than two tables 2024-12-22 00:58:23 -08:00
stack.h reftable: make the compaction factor configurable 2024-05-13 17:02:39 -07:00
system.h hash-ll: merge with "hash.h" 2024-06-14 10:26:33 -07:00
tree.c reftable/tree: handle allocation failures 2024-10-02 07:53:55 -07:00
tree.h reftable/tree: handle allocation failures 2024-10-02 07:53:55 -07:00
writer.c reftable: introduce `REFTABLE_FREE_AND_NULL()` 2024-10-02 07:53:56 -07:00
writer.h reftable: honor core.fsync 2024-01-23 13:45:27 -08:00