Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] box/txn: do not zap fiber txn pointer before txn_write_to_wal completes
@ 2020-01-24 15:17 Cyrill Gorcunov
  2020-01-24 15:24 ` Cyrill Gorcunov
  2020-01-31 19:44 ` Konstantin Osipov
  0 siblings, 2 replies; 5+ messages in thread
From: Cyrill Gorcunov @ 2020-01-24 15:17 UTC (permalink / raw)
  To: tml

The txn_write_to_wal operates with txn by own: on success it calls
txn_entry_done_cb which completes transaction, on error it calls
txn_rollback which expects the transaction we're rolling back is
the one the fiber carries in storage.

 | txn_write
 |   fiber_set_txn(fiber(), NULL); // zap fiber's storage.txn
 |   txn_write_to_wal(txn);
 |     journal_entry_new(..., txn_entry_done_cb, ...)
 |     if (req == NULL)
 |       txn_rollback(txn);
 |         assert(txn == in_txn()); // in_txn()=nil, triggers

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
Not for merging! I need to create a proper testcase with
error injection. Sending it out for early review since
I'm hunting another issue right now and this patch just
to not loose the info.

 src/box/txn.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/box/txn.c b/src/box/txn.c
index bedb57449..060d91536 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -583,7 +583,6 @@ txn_write(struct txn *txn)
 		fiber_set_txn(fiber(), NULL);
 		return 0;
 	}
-	fiber_set_txn(fiber(), NULL);
 	return txn_write_to_wal(txn);
 }
 
-- 
2.20.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Tarantool-patches] [PATCH] box/txn: do not zap fiber txn pointer before txn_write_to_wal completes
  2020-01-24 15:17 [Tarantool-patches] [PATCH] box/txn: do not zap fiber txn pointer before txn_write_to_wal completes Cyrill Gorcunov
@ 2020-01-24 15:24 ` Cyrill Gorcunov
  2020-01-31 19:44 ` Konstantin Osipov
  1 sibling, 0 replies; 5+ messages in thread
From: Cyrill Gorcunov @ 2020-01-24 15:24 UTC (permalink / raw)
  To: tml

On Fri, Jan 24, 2020 at 06:17:06PM +0300, Cyrill Gorcunov wrote:
> The txn_write_to_wal operates with txn by own: on success it calls
> txn_entry_done_cb which completes transaction, on error it calls
> txn_rollback which expects the transaction we're rolling back is
> the one the fiber carries in storage.

Drop it, it start triggering another error. Thus need more significant
investigation first.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Tarantool-patches] [PATCH] box/txn: do not zap fiber txn pointer before txn_write_to_wal completes
  2020-01-24 15:17 [Tarantool-patches] [PATCH] box/txn: do not zap fiber txn pointer before txn_write_to_wal completes Cyrill Gorcunov
  2020-01-24 15:24 ` Cyrill Gorcunov
@ 2020-01-31 19:44 ` Konstantin Osipov
  2020-01-31 19:57   ` Cyrill Gorcunov
  1 sibling, 1 reply; 5+ messages in thread
From: Konstantin Osipov @ 2020-01-31 19:44 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tml

* Cyrill Gorcunov <gorcunov@gmail.com> [20/01/24 18:18]:
> The txn_write_to_wal operates with txn by own: on success it calls
> txn_entry_done_cb which completes transaction, on error it calls
> txn_rollback which expects the transaction we're rolling back is
> the one the fiber carries in storage.
> 
>  | txn_write
>  |   fiber_set_txn(fiber(), NULL); // zap fiber's storage.txn
>  |   txn_write_to_wal(txn);
>  |     journal_entry_new(..., txn_entry_done_cb, ...)
>  |     if (req == NULL)
>  |       txn_rollback(txn);
>  |         assert(txn == in_txn()); // in_txn()=nil, triggers

Wile I agree this call chain is problematic...


> index bedb57449..060d91536 100644
> --- a/src/box/txn.c
> +++ b/src/box/txn.c
> @@ -583,7 +583,6 @@ txn_write(struct txn *txn)
>  		fiber_set_txn(fiber(), NULL);
>  		return 0;
>  	}
> -	fiber_set_txn(fiber(), NULL);
>  	return txn_write_to_wal(txn);

I believe Georgy added this for a reason - since the current fiber
is no longer locked until the transaction is resumed, it should
be removed from the fiber key (this change AFAIU comes from
parallel applier patch).

I suggest you move this statement inside txn_write_to_wal(). I
can't find a good place for it yet though.

-- 
Konstantin Osipov, Moscow, Russia

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Tarantool-patches] [PATCH] box/txn: do not zap fiber txn pointer before txn_write_to_wal completes
  2020-01-31 19:44 ` Konstantin Osipov
@ 2020-01-31 19:57   ` Cyrill Gorcunov
  2020-02-03 19:54     ` Georgy Kirichenko
  0 siblings, 1 reply; 5+ messages in thread
From: Cyrill Gorcunov @ 2020-01-31 19:57 UTC (permalink / raw)
  To: Konstantin Osipov; +Cc: tml

On Fri, Jan 31, 2020 at 10:44:48PM +0300, Konstantin Osipov wrote:
> 
> I believe Georgy added this for a reason - since the current fiber
> is no longer locked until the transaction is resumed, it should
> be removed from the fiber key (this change AFAIU comes from
> parallel applier patch).
> 
> I suggest you move this statement inside txn_write_to_wal(). I
> can't find a good place for it yet though.

Thanks for idea, Kostya! The my patch above didn't work simply
because if I don't set NULL here it start triggering assertion
in another places. IOW, I filed this issue and will back to
it on the next week I hope. I'll show you the result.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Tarantool-patches] [PATCH] box/txn: do not zap fiber txn pointer before txn_write_to_wal completes
  2020-01-31 19:57   ` Cyrill Gorcunov
@ 2020-02-03 19:54     ` Georgy Kirichenko
  0 siblings, 0 replies; 5+ messages in thread
From: Georgy Kirichenko @ 2020-02-03 19:54 UTC (permalink / raw)
  To: Konstantin Osipov, tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 1684 bytes --]

On Friday, 31 January 2020 22:57:23 MSK Cyrill Gorcunov wrote:
> On Fri, Jan 31, 2020 at 10:44:48PM +0300, Konstantin Osipov wrote:
> > I believe Georgy added this for a reason - since the current fiber
> > is no longer locked until the transaction is resumed, it should
> > be removed from the fiber key (this change AFAIU comes from
> > parallel applier patch).
> > 
> > I suggest you move this statement inside txn_write_to_wal(). I
> > can't find a good place for it yet though.
> 
> Thanks for idea, Kostya! The my patch above didn't work simply
> because if I don't set NULL here it start triggering assertion
> in another places. IOW, I filed this issue and will back to
> it on the next week I hope. I'll show you the result.

Kostja is right - the intention was to detach a transaction from a fiber.
The first step is being able to fire a transaction to wal and forget aboit it 
because all transaction finalization logic could be implemented via on_commit/
on_rollback trigger.  The reason to setup fiber while transaction on_commit/
on_rollback is backward compatibility - some transaction finalization triggers 
use in_txn() macro. So it makes the applier able to process transactions 
logging in parallel.
The second step I would like to implement is processing more than one 
transaction simultaneously, for instance we can be able to fire an autonomous 
transaction for sequences while a primary transaction still in progress and 
preserve such autonomous transaction effect even when the primary one is going 
to be rolled back.
Note: the second feature is limited until a transaction manager is implemented 
because simultaneous transactions shall be non-conflicting.

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-03 19:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24 15:17 [Tarantool-patches] [PATCH] box/txn: do not zap fiber txn pointer before txn_write_to_wal completes Cyrill Gorcunov
2020-01-24 15:24 ` Cyrill Gorcunov
2020-01-31 19:44 ` Konstantin Osipov
2020-01-31 19:57   ` Cyrill Gorcunov
2020-02-03 19:54     ` Georgy Kirichenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox