refs/reftable: introduce "reftable.lockTimeout"
When multiple concurrent processes try to update references in a repository they may try to lock the same lockfiles. This can happen even when the updates are non-conflicting and can both be applied, so it doesn't always make sense to abort the transaction immediately. Both the "loose" and "packed" backends thus have a grace period that they wait for the lock to be released that can be controlled via the config values "core.filesRefLockTimeout" and "core.packedRefsTimeout", respectively. The reftable backend doesn't have such a setting yet and instead fails immediately when it sees such a lock. But the exact same concepts apply here as they do apply to the other backends. Introduce a new "reftable.lockTimeout" config that controls how long we may wait for a "tables.list" lock to be released. The default value of this config is 100ms, which is the same default as we have it for the "loose" backend. Note that even though we also lock individual tables, this config really only applies to the "tables.list" file. This is because individual tables are only ever locked when we already hold the "tables.list" lock during compaction. When we observe such a lock we in fact do not want to compact the table at all because it is already in the process of being compacted by a concurrent process. So applying the same timeout here would not make any sense and only delay progress. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
6531f31ef3
commit
bc39b6a796
@ -603,8 +603,10 @@ static int reftable_stack_init_addition(struct reftable_addition *add,
|
||||
|
||||
add->stack = st;
|
||||
|
||||
err = hold_lock_file_for_update(&add->tables_list_lock, st->list_file,
|
||||
LOCK_NO_DEREF);
|
||||
err = hold_lock_file_for_update_timeout(&add->tables_list_lock,
|
||||
st->list_file,
|
||||
LOCK_NO_DEREF,
|
||||
st->opts.lock_timeout_ms);
|
||||
if (err < 0) {
|
||||
if (errno == EEXIST) {
|
||||
err = REFTABLE_LOCK_ERROR;
|
||||
@ -1056,8 +1058,10 @@ static int stack_compact_range(struct reftable_stack *st,
|
||||
* Hold the lock so that we can read "tables.list" and lock all tables
|
||||
* which are part of the user-specified range.
|
||||
*/
|
||||
err = hold_lock_file_for_update(&tables_list_lock, st->list_file,
|
||||
LOCK_NO_DEREF);
|
||||
err = hold_lock_file_for_update_timeout(&tables_list_lock,
|
||||
st->list_file,
|
||||
LOCK_NO_DEREF,
|
||||
st->opts.lock_timeout_ms);
|
||||
if (err < 0) {
|
||||
if (errno == EEXIST)
|
||||
err = REFTABLE_LOCK_ERROR;
|
||||
@ -1156,8 +1160,10 @@ static int stack_compact_range(struct reftable_stack *st,
|
||||
* "tables.list". We'll then replace the compacted range of tables with
|
||||
* the new table.
|
||||
*/
|
||||
err = hold_lock_file_for_update(&tables_list_lock, st->list_file,
|
||||
LOCK_NO_DEREF);
|
||||
err = hold_lock_file_for_update_timeout(&tables_list_lock,
|
||||
st->list_file,
|
||||
LOCK_NO_DEREF,
|
||||
st->opts.lock_timeout_ms);
|
||||
if (err < 0) {
|
||||
if (errno == EEXIST)
|
||||
err = REFTABLE_LOCK_ERROR;
|
||||
|
Reference in New Issue
Block a user