Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH] box: ensure fiber processing box.cfg doesn't process messages from iproto
@ 2018-11-10 11:24 Serge Petrenko
  2018-11-12 11:40 ` Vladimir Davydov
  0 siblings, 1 reply; 4+ messages in thread
From: Serge Petrenko @ 2018-11-10 11:24 UTC (permalink / raw)
  To: vdavydov.dev; +Cc: tarantool-patches, Serge Petrenko

In box_cfg() we have a call to gc_set_wal_watcher(), which creates pipes
between 'wal' and 'tx' under the hood using cbus_pair().
While pipes are being created, the fiber calling gc_set_wal_watcher()
will process all the messages coming to 'tx' thread from iproto. This is
wrong, since we have a separate fiber pool to handle iproto messages,
and background fibers shouldn't participate in these messages
processing. For example, this causes occasional credential corruption in
the fiber executing box_cfg().

Since tx fiber pool is already created at the time gc_set_wal_watcher()
is called, we may forbid message processing for the fiber which calls
the function, one of the tx fiber pool fibers will wake us up when the
pipes are created.

Closes #3779
---
https://github.com/tarantool/tarantool/tree/sp/gh-3779-fix
https://github.com/tarantool/tarantool/issues/3779

 src/box/gc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/box/gc.c b/src/box/gc.c
index 467eecb91..8f0ecb0b9 100644
--- a/src/box/gc.c
+++ b/src/box/gc.c
@@ -110,7 +110,7 @@ void
 gc_set_wal_watcher(void)
 {
 	wal_set_watcher(&gc.wal_watcher, "tx", gc_process_wal_event,
-			cbus_process, WAL_EVENT_GC);
+			NULL, WAL_EVENT_GC);
 }
 
 void
-- 
2.17.2 (Apple Git-113)

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

* Re: [PATCH] box: ensure fiber processing box.cfg doesn't process messages from iproto
  2018-11-10 11:24 [PATCH] box: ensure fiber processing box.cfg doesn't process messages from iproto Serge Petrenko
@ 2018-11-12 11:40 ` Vladimir Davydov
  2018-11-13  6:54   ` Serge Petrenko
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Davydov @ 2018-11-12 11:40 UTC (permalink / raw)
  To: Serge Petrenko; +Cc: tarantool-patches

On Sat, Nov 10, 2018 at 02:24:36PM +0300, Serge Petrenko wrote:
> In box_cfg() we have a call to gc_set_wal_watcher(), which creates pipes
> between 'wal' and 'tx' under the hood using cbus_pair().
> While pipes are being created, the fiber calling gc_set_wal_watcher()
> will process all the messages coming to 'tx' thread from iproto. This is
> wrong, since we have a separate fiber pool to handle iproto messages,
> and background fibers shouldn't participate in these messages
> processing. For example, this causes occasional credential corruption in
> the fiber executing box_cfg().
> 
> Since tx fiber pool is already created at the time gc_set_wal_watcher()
> is called, we may forbid message processing for the fiber which calls
> the function, one of the tx fiber pool fibers will wake us up when the
> pipes are created.
> 
> Closes #3779
> ---
> https://github.com/tarantool/tarantool/tree/sp/gh-3779-fix
> https://github.com/tarantool/tarantool/issues/3779
> 
>  src/box/gc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/box/gc.c b/src/box/gc.c
> index 467eecb91..8f0ecb0b9 100644
> --- a/src/box/gc.c
> +++ b/src/box/gc.c
> @@ -110,7 +110,7 @@ void
>  gc_set_wal_watcher(void)
>  {

Please add a comment to the code, otherwise the patch looks OK.

>  	wal_set_watcher(&gc.wal_watcher, "tx", gc_process_wal_event,
> -			cbus_process, WAL_EVENT_GC);
> +			NULL, WAL_EVENT_GC);
>  }
>  
>  void

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

* Re: [PATCH] box: ensure fiber processing box.cfg doesn't process messages from iproto
  2018-11-12 11:40 ` Vladimir Davydov
@ 2018-11-13  6:54   ` Serge Petrenko
  2018-11-13  9:31     ` Vladimir Davydov
  0 siblings, 1 reply; 4+ messages in thread
From: Serge Petrenko @ 2018-11-13  6:54 UTC (permalink / raw)
  To: Vladimir Davydov; +Cc: tarantool-patches

Hi!

12 нояб. 2018 г., в 14:40, Vladimir Davydov <vdavydov.dev@gmail.com> написал(а):
> 
> On Sat, Nov 10, 2018 at 02:24:36PM +0300, Serge Petrenko wrote:
>> 
>> diff --git a/src/box/gc.c b/src/box/gc.c
>> index 467eecb91..8f0ecb0b9 100644
>> --- a/src/box/gc.c
>> +++ b/src/box/gc.c
>> @@ -110,7 +110,7 @@ void
>> gc_set_wal_watcher(void)
>> {
> 
> Please add a comment to the code, otherwise the patch looks OK.

Added the comment, the diff’s below.

> 
>> 	wal_set_watcher(&gc.wal_watcher, "tx", gc_process_wal_event,
>> -			cbus_process, WAL_EVENT_GC);
>> +			NULL, WAL_EVENT_GC);
>> }
>> 
>> void


diff --git a/src/box/gc.c b/src/box/gc.c
index 467eecb91..cefe1553f 100644
--- a/src/box/gc.c
+++ b/src/box/gc.c
@@ -109,8 +109,18 @@ gc_process_wal_event(struct wal_watcher_msg *);
 void
 gc_set_wal_watcher(void)
 {
+	/*
+	 * Since the function is called from box_cfg() it is
+	 * important that we do not pass a message processing
+	 * callback to wal_set_watcher(). Doing so would cause
+	 * credentials corruption in the fiber executing
+	 * box_cfg() in case it processes some iproto messages.
+	 * Besides, by the time the function is called
+	 * tx_fiber_pool is already set up and it will process
+	 * all the messages directed to "tx" endpoint safely.
+	 */
 	wal_set_watcher(&gc.wal_watcher, "tx", gc_process_wal_event,
-			cbus_process, WAL_EVENT_GC);
+			NULL, WAL_EVENT_GC);
 }
 
 void
-- 
2.17.2 (Apple Git-113)

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

* Re: [PATCH] box: ensure fiber processing box.cfg doesn't process messages from iproto
  2018-11-13  6:54   ` Serge Petrenko
@ 2018-11-13  9:31     ` Vladimir Davydov
  0 siblings, 0 replies; 4+ messages in thread
From: Vladimir Davydov @ 2018-11-13  9:31 UTC (permalink / raw)
  To: Serge Petrenko; +Cc: tarantool-patches

On Tue, Nov 13, 2018 at 09:54:40AM +0300, Serge Petrenko wrote:
> >> diff --git a/src/box/gc.c b/src/box/gc.c
> >> index 467eecb91..8f0ecb0b9 100644
> >> --- a/src/box/gc.c
> >> +++ b/src/box/gc.c
> >> @@ -110,7 +110,7 @@ void
> >> gc_set_wal_watcher(void)
> >> {
> > 
> > Please add a comment to the code, otherwise the patch looks OK.
> 
> Added the comment, the diff’s below.

Pushed to 1.10-features.

> 
> > 
> >> 	wal_set_watcher(&gc.wal_watcher, "tx", gc_process_wal_event,
> >> -			cbus_process, WAL_EVENT_GC);
> >> +			NULL, WAL_EVENT_GC);
> >> }
> >> 
> >> void
> 
> 
> diff --git a/src/box/gc.c b/src/box/gc.c
> index 467eecb91..cefe1553f 100644
> --- a/src/box/gc.c
> +++ b/src/box/gc.c
> @@ -109,8 +109,18 @@ gc_process_wal_event(struct wal_watcher_msg *);
>  void
>  gc_set_wal_watcher(void)
>  {
> +	/*
> +	 * Since the function is called from box_cfg() it is
> +	 * important that we do not pass a message processing
> +	 * callback to wal_set_watcher(). Doing so would cause
> +	 * credentials corruption in the fiber executing
> +	 * box_cfg() in case it processes some iproto messages.
> +	 * Besides, by the time the function is called
> +	 * tx_fiber_pool is already set up and it will process
> +	 * all the messages directed to "tx" endpoint safely.
> +	 */
>  	wal_set_watcher(&gc.wal_watcher, "tx", gc_process_wal_event,
> -			cbus_process, WAL_EVENT_GC);
> +			NULL, WAL_EVENT_GC);

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

end of thread, other threads:[~2018-11-13  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-10 11:24 [PATCH] box: ensure fiber processing box.cfg doesn't process messages from iproto Serge Petrenko
2018-11-12 11:40 ` Vladimir Davydov
2018-11-13  6:54   ` Serge Petrenko
2018-11-13  9:31     ` Vladimir Davydov

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