Merge branch 'ps/reftable-concurrent-writes'
Give timeout to the locking code to write to reftable. * ps/reftable-concurrent-writes: refs/reftable: reload locked stack when preparing transaction reftable/stack: allow locking of outdated stacks refs/reftable: introduce "reftable.lockTimeout"
This commit is contained in:
@ -260,6 +260,13 @@ static int reftable_be_config(const char *var, const char *value,
|
||||
if (factor > UINT8_MAX)
|
||||
die("reftable geometric factor cannot exceed %u", (unsigned)UINT8_MAX);
|
||||
opts->auto_compaction_factor = factor;
|
||||
} else if (!strcmp(var, "reftable.locktimeout")) {
|
||||
int64_t lock_timeout = git_config_int64(var, value, ctx->kvi);
|
||||
if (lock_timeout > LONG_MAX)
|
||||
die("reftable lock timeout cannot exceed %"PRIdMAX, (intmax_t)LONG_MAX);
|
||||
if (lock_timeout < 0 && lock_timeout != -1)
|
||||
die("reftable lock timeout does not support negative values other than -1");
|
||||
opts->lock_timeout_ms = lock_timeout;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -286,6 +293,7 @@ static struct ref_store *reftable_be_init(struct repository *repo,
|
||||
refs->write_options.default_permissions = calc_shared_perm(0666 & ~mask);
|
||||
refs->write_options.disable_auto_compact =
|
||||
!git_env_bool("GIT_TEST_REFTABLE_AUTOCOMPACTION", 1);
|
||||
refs->write_options.lock_timeout_ms = 100;
|
||||
|
||||
git_config(reftable_be_config, &refs->write_options);
|
||||
|
||||
@ -893,7 +901,8 @@ static int prepare_transaction_update(struct write_transaction_table_arg **out,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = reftable_stack_new_addition(&addition, stack);
|
||||
ret = reftable_stack_new_addition(&addition, stack,
|
||||
REFTABLE_STACK_NEW_ADDITION_RELOAD);
|
||||
if (ret) {
|
||||
if (ret == REFTABLE_LOCK_ERROR)
|
||||
strbuf_addstr(err, "cannot lock references");
|
||||
@ -2330,7 +2339,7 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
ret = reftable_stack_new_addition(&add, stack);
|
||||
ret = reftable_stack_new_addition(&add, stack, 0);
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
|
Reference in New Issue
Block a user