Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Георгий Кириченко" <georgy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>, kostja@tarantool.org
Subject: Re: [tarantool-patches] [PATCH 2/4] vinyl: don't abort transactions that modify only local spaces for ro
Date: Mon, 25 Mar 2019 08:27:28 +0300	[thread overview]
Message-ID: <1860307.laWNLuDzhG@home.lan> (raw)
In-Reply-To: <7add57ecaf0970eaf56dc248edbd81c3d28d64b6.1553373793.git.vdavydov.dev@gmail.com>

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

I think it is out of scope of the task.

On Sunday, March 24, 2019 12:07:22 AM MSK Vladimir Davydov wrote:
> Local spaces can be modified even in read-only mode hence we don't need
> to abort transactions that modify only local spaces when switching to
> read-only mode.
> 
> Follow-up #4016
> ---
>  src/box/vy_tx.c          | 19 +++++++++++++++++--
>  test/vinyl/misc.result   | 38 ++++++++++++++++++++++++++++++++++++++
>  test/vinyl/misc.test.lua | 16 ++++++++++++++++
>  3 files changed, 71 insertions(+), 2 deletions(-)
> 
> diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c
> index 56d594e5..67a9b384 100644
> --- a/src/box/vy_tx.c
> +++ b/src/box/vy_tx.c
> @@ -52,6 +52,7 @@
>  #include "trivia/util.h"
>  #include "tuple.h"
>  #include "column_mask.h"
> +#include "vclock.h"
>  #include "vy_cache.h"
>  #include "vy_lsm.h"
>  #include "vy_mem.h"
> @@ -1121,8 +1122,22 @@ tx_manager_abort_writers_for_ro(struct tx_manager
> *xm) struct vy_tx *tx;
>  	rlist_foreach_entry(tx, &xm->writers, in_writers) {
>  		/* Applier ignores ro flag. */
> -		if (tx->state == VINYL_TX_READY && !tx->is_applier_session)
> -			vy_tx_abort(tx);
> +		if (tx->state == VINYL_TX_READY && !tx->is_applier_session) {
> +			/*
> +			 * Don't abort transactions that modify only
> +			 * local spaces as they can be modified even
> +			 * in ro mode.
> +			 */
> +			struct vy_tx_space_hash_entry *entry;
> +			struct vy_tx_space_hash_iterator it;
> +			vy_tx_space_hash_ifirst(&tx->space_hash, &it);
> +			while ((entry = vy_tx_space_hash_inext(&it)) != NULL) {
> +				if (space_group_id(entry->space) != GROUP_LOCAL) 
{
> +					vy_tx_abort(tx);
> +					break;
> +				}
> +			}
> +		}
>  	}
>  }
> 
> diff --git a/test/vinyl/misc.result b/test/vinyl/misc.result
> index 4f613cb0..751f8795 100644
> --- a/test/vinyl/misc.result
> +++ b/test/vinyl/misc.result
> @@ -298,6 +298,16 @@ s:replace({1, 1})
>  ---
>  - [1, 1]
>  ...
> +s_local = box.schema.space.create('test_local', {engine = 'vinyl', is_local
> = true}) +---
> +...
> +_ = s_local:create_index('pk')
> +---
> +...
> +s_local:replace({1, 1})
> +---
> +- [1, 1]
> +...
>  test_run:cmd("setopt delimiter ';'")
>  ---
>  - true
> @@ -334,6 +344,19 @@ _ = fiber.create(function()
>  end);
>  ---
>  ...
> +-- Start rw transaction modifying only local spaces.
> +ch3 = fiber.channel(1);
> +---
> +...
> +_ = fiber.create(function()
> +    box.begin()
> +    s_local:replace{1, 2}
> +    ch3:get()
> +    local status, err = pcall(box.commit)
> +    ch3:put(status or err)
> +end);
> +---
> +...
>  test_run:cmd("setopt delimiter ''");
>  ---
>  - true
> @@ -351,6 +374,10 @@ ch2:put(true)
>  ---
>  - true
>  ...
> +ch3:put(true)
> +---
> +- true
> +...
>  ch1:get()
>  ---
>  - Can't modify data because this instance is in read-only mode.
> @@ -371,6 +398,10 @@ ch2:get()
>  ---
>  - true
>  ...
> +ch3:get()
> +---
> +- true
> +...
>  -- Cleanup.
>  box.cfg{read_only = false}
>  ---
> @@ -382,3 +413,10 @@ s:select()
>  s:drop()
>  ---
>  ...
> +s_local:select()
> +---
> +- - [1, 2]
> +...
> +s_local:drop()
> +---
> +...
> diff --git a/test/vinyl/misc.test.lua b/test/vinyl/misc.test.lua
> index bffaaf16..0616722f 100644
> --- a/test/vinyl/misc.test.lua
> +++ b/test/vinyl/misc.test.lua
> @@ -124,6 +124,9 @@ test_run:cmd('cleanup server test')
>  s = box.schema.space.create('test', {engine = 'vinyl'})
>  _ = s:create_index('pk')
>  s:replace({1, 1})
> +s_local = box.schema.space.create('test_local', {engine = 'vinyl', is_local
> = true}) +_ = s_local:create_index('pk')
> +s_local:replace({1, 1})
>  test_run:cmd("setopt delimiter ';'")
>  -- Start rw transaction.
>  ch1 = fiber.channel(1);
> @@ -149,18 +152,31 @@ _ = fiber.create(function()
>      local status, err = pcall(box.commit)
>      ch2:put(status or err)
>  end);
> +-- Start rw transaction modifying only local spaces.
> +ch3 = fiber.channel(1);
> +_ = fiber.create(function()
> +    box.begin()
> +    s_local:replace{1, 2}
> +    ch3:get()
> +    local status, err = pcall(box.commit)
> +    ch3:put(status or err)
> +end);
>  test_run:cmd("setopt delimiter ''");
>  -- Switch to ro mode.
>  box.cfg{read_only = true}
>  -- Resume the transactions.
>  ch1:put(true)
>  ch2:put(true)
> +ch3:put(true)
>  ch1:get()
>  ch1:get()
>  ch1:get()
>  ch2:get()
>  ch2:get()
> +ch3:get()
>  -- Cleanup.
>  box.cfg{read_only = false}
>  s:select()
>  s:drop()
> +s_local:select()
> +s_local:drop()


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

  reply	other threads:[~2019-03-25  5:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-23 21:07 [PATCH 0/4] Fix DML vs DDL race Vladimir Davydov
2019-03-23 21:07 ` [PATCH 1/4] vinyl: introduce hash of spaces affected by transaction Vladimir Davydov
2019-03-28 13:25   ` [tarantool-patches] " Konstantin Osipov
2019-03-28 13:58     ` Vladimir Davydov
2019-03-23 21:07 ` [PATCH 2/4] vinyl: don't abort transactions that modify only local spaces for ro Vladimir Davydov
2019-03-25  5:27   ` Георгий Кириченко [this message]
2019-03-25  8:13     ` [tarantool-patches] " Vladimir Davydov
2019-03-25  8:58       ` Георгий Кириченко
2019-03-25  9:30         ` Vladimir Davydov
2019-03-23 21:07 ` [PATCH 3/4] vinyl: abort affected transactions when space is removed from cache Vladimir Davydov
2019-03-25  5:26   ` [tarantool-patches] " Георгий Кириченко
2019-03-25  8:17     ` Vladimir Davydov
     [not found]       ` <1564677.EMV258VVK2@home.lan>
2019-03-25  9:51         ` Vladimir Davydov
2019-03-25  5:45   ` Георгий Кириченко
2019-03-25  8:21     ` Vladimir Davydov
2019-03-25  9:03       ` Георгий Кириченко
2019-03-28 13:45   ` [tarantool-patches] " Konstantin Osipov
2019-03-28 14:02     ` Vladimir Davydov
2019-03-28 14:12       ` Konstantin Osipov
2019-03-23 21:07 ` [PATCH 4/4] Revert "test: skip ddl test for vinyl on travis" Vladimir Davydov
2019-03-28 13:46   ` [tarantool-patches] " Konstantin Osipov

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=1860307.laWNLuDzhG@home.lan \
    --to=georgy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [tarantool-patches] [PATCH 2/4] vinyl: don'\''t abort transactions that modify only local spaces for ro' \
    /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

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