diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-03-25 11:02:50 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-03-25 09:54:07 -0700 |
| commit | a2f711ade0c4816a59155d72559cbc4759cd4699 (patch) | |
| tree | 5c3a8c6423e640d428a4ef88875269bae32a0ef4 /reftable/stack.c | |
| parent | 33358350eb857a5fb273d143dcdfe15ac6d4db5d (diff) | |
| download | git-a2f711ade0c4816a59155d72559cbc4759cd4699.tar.xz | |
reftable/stack: gracefully handle failed auto-compaction due to locks
Whenever we commit a new table to the reftable stack we will end up
invoking auto-compaction of the stack to keep the total number of tables
at bay. This auto-compaction may fail though in case at least one of the
tables which we are about to compact is locked. This is indicated by the
compaction function returning `REFTABLE_LOCK_ERROR`. We do not handle
this case though, and thus bubble that return value up the calling
chain, which will ultimately cause a failure.
Fix this bug by ignoring `REFTABLE_LOCK_ERROR`.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/stack.c')
| -rw-r--r-- | reftable/stack.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/reftable/stack.c b/reftable/stack.c index 79856b6565..dde50b61d6 100644 --- a/reftable/stack.c +++ b/reftable/stack.c @@ -680,8 +680,19 @@ int reftable_addition_commit(struct reftable_addition *add) if (err) goto done; - if (!add->stack->disable_auto_compact) + if (!add->stack->disable_auto_compact) { + /* + * Auto-compact the stack to keep the number of tables in + * control. It is possible that a concurrent writer is already + * trying to compact parts of the stack, which would lead to a + * `REFTABLE_LOCK_ERROR` because parts of the stack are locked + * already. This is a benign error though, so we ignore it. + */ err = reftable_stack_auto_compact(add->stack); + if (err < 0 && err != REFTABLE_LOCK_ERROR) + goto done; + err = 0; + } done: reftable_addition_close(add); |
