From: Patrick Steinhardt <ps@pks.im>
To: James Liu <james@jamesliu.io>
Cc: git@vger.kernel.org, karthik nayak <karthik.188@gmail.com>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v2 2/3] reftable/stack: allow locking of outdated stacks
Date: Wed, 18 Sep 2024 11:39:10 +0200 [thread overview]
Message-ID: <Zuqfvp_vaALkuERP@pks.im> (raw)
In-Reply-To: <D49AWUZ2NCNC.11D23I38TRE0B@jamesliu.io>
On Wed, Sep 18, 2024 at 07:26:49PM +1000, James Liu wrote:
> I just want to check my understanding of this test, since I think it's
> the first time I've reviewed anything using this test harness:
>
> On Wed Sep 18, 2024 at 2:32 PM AEST, Patrick Steinhardt wrote:
> > diff --git a/t/unit-tests/t-reftable-stack.c b/t/unit-tests/t-reftable-stack.c
> > index d62a9c1bed5..a37cc698d87 100644
> > --- a/t/unit-tests/t-reftable-stack.c
> > +++ b/t/unit-tests/t-reftable-stack.c
> > @@ -271,7 +271,7 @@ static void t_reftable_stack_transaction_api(void)
> >
> > reftable_addition_destroy(add);
> >
> > - err = reftable_stack_new_addition(&add, st);
> > + err = reftable_stack_new_addition(&add, st, 0);
> > check(!err);
> >
> > err = reftable_addition_add(add, write_test_ref, &ref);
> > @@ -292,6 +292,68 @@ static void t_reftable_stack_transaction_api(void)
> > clear_dir(dir);
> > }
> >
> > +static void t_reftable_stack_transaction_with_reload(void)
> > +{
> > + char *dir = get_tmp_dir(__LINE__);
> > + struct reftable_stack *st1 = NULL, *st2 = NULL;
> > + int err;
> > + struct reftable_addition *add = NULL;
> > + struct reftable_ref_record refs[2] = {
> > + {
> > + .refname = (char *) "refs/heads/a",
> > + .update_index = 1,
> > + .value_type = REFTABLE_REF_VAL1,
> > + .value.val1 = { '1' },
> > + },
> > + {
> > + .refname = (char *) "refs/heads/b",
> > + .update_index = 2,
> > + .value_type = REFTABLE_REF_VAL1,
> > + .value.val1 = { '1' },
> > + },
> > + };
> > + struct reftable_ref_record ref = { 0 };
> > +
>
> Create two reftable stacks that provide a view into the reftable tables
> inside "dir".
Yup.
> > + err = reftable_new_stack(&st1, dir, NULL);
> > + check(!err);
> > + err = reftable_new_stack(&st2, dir, NULL);
> > + check(!err);
> > +
>
> Successfully add refs[0] to the first stack using the transactional API.
Here we only open the stacks without doing anything with them yet. This
is preparation for being able to read/write them.
> > + err = reftable_stack_new_addition(&add, st1, 0);
> > + check(!err);
> > + err = reftable_addition_add(add, write_test_ref, &refs[0]);
> > + check(!err);
> > + err = reftable_addition_commit(add);
> > + check(!err);
> > + reftable_addition_destroy(add);
> > +
> > + /*
> > + * The second stack is now outdated, which we should notice. We do not
> > + * create the addition and lock the stack by default, but allow the
> > + * reload to happen when REFTABLE_STACK_NEW_ADDITION_RELOAD is set.
> > + */
>
> We try to open a transaction via the second reftable stack, but the
> this stack is outdated because we've written to "dir" when the previous
> stack addition was committed.
Yup.
> > + err = reftable_stack_new_addition(&add, st2, 0);
> > + check_int(err, ==, REFTABLE_OUTDATED_ERROR);
>
> Try again, but supply the flag so it performs a reload internally. Write
> refs[1] to "dir" by committing the transaction.
Yup.
> > + err = reftable_stack_new_addition(&add, st2, REFTABLE_STACK_NEW_ADDITION_RELOAD);
> > + check(!err);
> > + err = reftable_addition_add(add, write_test_ref, &refs[1]);
> > + check(!err);
> > + err = reftable_addition_commit(add);
> > + check(!err);
> > + reftable_addition_destroy(add);
> > +
>
> Asserts.
Exactly.
Patrick
next prev parent reply other threads:[~2024-09-18 9:39 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-17 13:43 [PATCH 0/3] reftable: graceful concurrent writes Patrick Steinhardt
2024-09-17 13:43 ` [PATCH 1/3] refs/reftable: introduce "reftable.lockTimeout" Patrick Steinhardt
2024-09-17 17:46 ` karthik nayak
2024-09-17 17:50 ` Eric Sunshine
2024-09-18 4:31 ` Patrick Steinhardt
2024-09-18 4:31 ` Patrick Steinhardt
2024-09-17 13:43 ` [PATCH 2/3] reftable/stack: allow locking of outdated stacks Patrick Steinhardt
2024-09-17 13:43 ` [PATCH 3/3] refs/reftable: reload locked stack when preparing transaction Patrick Steinhardt
2024-09-17 18:26 ` [PATCH 0/3] reftable: graceful concurrent writes karthik nayak
2024-09-18 4:31 ` Patrick Steinhardt
2024-09-18 4:32 ` [PATCH v2 " Patrick Steinhardt
2024-09-18 4:32 ` [PATCH v2 1/3] refs/reftable: introduce "reftable.lockTimeout" Patrick Steinhardt
2024-09-18 9:22 ` James Liu
2024-09-18 9:39 ` Patrick Steinhardt
2024-09-18 4:32 ` [PATCH v2 2/3] reftable/stack: allow locking of outdated stacks Patrick Steinhardt
2024-09-18 9:26 ` James Liu
2024-09-18 9:39 ` Patrick Steinhardt [this message]
2024-09-18 4:32 ` [PATCH v2 3/3] refs/reftable: reload locked stack when preparing transaction Patrick Steinhardt
2024-09-18 9:33 ` [PATCH v2 0/3] reftable: graceful concurrent writes James Liu
2024-09-18 9:59 ` [PATCH v3 " Patrick Steinhardt
2024-09-18 9:59 ` [PATCH v3 1/3] refs/reftable: introduce "reftable.lockTimeout" Patrick Steinhardt
2024-09-19 21:34 ` Junio C Hamano
2024-09-18 9:59 ` [PATCH v3 2/3] reftable/stack: allow locking of outdated stacks Patrick Steinhardt
2024-09-20 18:10 ` Junio C Hamano
2024-09-24 5:33 ` Patrick Steinhardt
2024-09-18 9:59 ` [PATCH v3 3/3] refs/reftable: reload locked stack when preparing transaction Patrick Steinhardt
2024-09-18 23:23 ` [PATCH v3 0/3] reftable: graceful concurrent writes James Liu
2024-09-24 5:33 ` Patrick Steinhardt
2024-09-24 5:32 ` [PATCH v4 " Patrick Steinhardt
2024-09-24 5:33 ` [PATCH v4 1/3] refs/reftable: introduce "reftable.lockTimeout" Patrick Steinhardt
2024-09-24 5:33 ` [PATCH v4 2/3] reftable/stack: allow locking of outdated stacks Patrick Steinhardt
2024-09-24 5:33 ` [PATCH v4 3/3] refs/reftable: reload locked stack when preparing transaction Patrick Steinhardt
2024-09-27 4:07 ` Jeff King
2024-09-30 6:49 ` Patrick Steinhardt
2024-09-30 22:19 ` Josh Steadmon
2024-10-01 4:27 ` Patrick Steinhardt
2024-10-01 22:54 ` Jeff King
2024-10-01 23:24 ` Junio C Hamano
2024-10-02 10:58 ` Patrick Steinhardt
2024-10-01 7:34 ` Junio C Hamano
2024-10-01 18:53 ` Josh Steadmon
2024-10-01 19:08 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zuqfvp_vaALkuERP@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=james@jamesliu.io \
--cc=karthik.188@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).