From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH 01/12] vinyl: use vy_lsm_env::empty_key where appropriate
Date: Thu, 21 Feb 2019 13:26:01 +0300 [thread overview]
Message-ID: <559411db1be54b5dcfcc40ee882275235c20dcd0.1550744027.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1550744027.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1550744027.git.vdavydov.dev@gmail.com>
No need to allocate an empty key during DDL - we already have one
preallocated in vy_lsm_env.
---
src/box/vinyl.c | 34 ++++++++++------------------------
src/box/vy_tx.c | 10 +++-------
src/box/vy_tx.h | 4 +---
3 files changed, 14 insertions(+), 34 deletions(-)
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 947ca355..23c5b9c3 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -1038,17 +1038,15 @@ vinyl_space_prepare_alter(struct space *old_space, struct space *new_space)
* before the trigger was installed so that DDL doesn't miss
* their working set.
*/
-static int
+static void
vy_abort_writers_for_ddl(struct vy_env *env, struct vy_lsm *lsm)
{
- if (tx_manager_abort_writers(env->xm, lsm) != 0)
- return -1;
+ tx_manager_abort_writers(env->xm, lsm);
/*
* Wait for prepared transactions to complete
* (we can't abort them as they reached WAL).
*/
wal_sync();
- return 0;
}
/** Argument passed to vy_check_format_on_replace(). */
@@ -1109,10 +1107,6 @@ vinyl_space_check_format(struct space *space, struct tuple_format *format)
*/
struct vy_lsm *pk = vy_lsm(space->index[0]);
- struct tuple *key = vy_stmt_new_select(pk->env->key_format, NULL, 0);
- if (key == NULL)
- return -1;
-
struct trigger on_replace;
struct vy_check_format_ctx ctx;
ctx.format = format;
@@ -1121,13 +1115,12 @@ vinyl_space_check_format(struct space *space, struct tuple_format *format)
trigger_create(&on_replace, vy_check_format_on_replace, &ctx, NULL);
trigger_add(&space->on_replace, &on_replace);
- int rc = vy_abort_writers_for_ddl(env, pk);
- if (rc != 0)
- goto out;
+ vy_abort_writers_for_ddl(env, pk);
struct vy_read_iterator itr;
- vy_read_iterator_open(&itr, pk, NULL, ITER_ALL, key,
+ vy_read_iterator_open(&itr, pk, NULL, ITER_ALL, pk->env->empty_key,
&env->xm->p_committed_read_view);
+ int rc;
int loops = 0;
struct tuple *tuple;
while ((rc = vy_read_iterator_next(&itr, &tuple)) == 0) {
@@ -1151,10 +1144,9 @@ vinyl_space_check_format(struct space *space, struct tuple_format *format)
break;
}
vy_read_iterator_close(&itr);
-out:
+
diag_destroy(&ctx.diag);
trigger_clear(&on_replace);
- tuple_unref(key);
return rc;
}
@@ -4183,10 +4175,6 @@ vinyl_space_build_index(struct space *src_space, struct index *new_index,
* may yield, we install an on_replace trigger to forward
* DML requests issued during the build.
*/
- struct tuple *key = vy_stmt_new_select(pk->env->key_format, NULL, 0);
- if (key == NULL)
- return -1;
-
struct trigger on_replace;
struct vy_build_ctx ctx;
ctx.lsm = new_lsm;
@@ -4198,13 +4186,12 @@ vinyl_space_build_index(struct space *src_space, struct index *new_index,
trigger_create(&on_replace, vy_build_on_replace, &ctx, NULL);
trigger_add(&src_space->on_replace, &on_replace);
- int rc = vy_abort_writers_for_ddl(env, pk);
- if (rc != 0)
- goto out;
+ vy_abort_writers_for_ddl(env, pk);
struct vy_read_iterator itr;
- vy_read_iterator_open(&itr, pk, NULL, ITER_ALL, key,
+ vy_read_iterator_open(&itr, pk, NULL, ITER_ALL, pk->env->empty_key,
&env->xm->p_committed_read_view);
+ int rc;
int loops = 0;
struct tuple *tuple;
int64_t build_lsn = env->xm->lsn;
@@ -4260,10 +4247,9 @@ vinyl_space_build_index(struct space *src_space, struct index *new_index,
diag_move(&ctx.diag, diag_get());
rc = -1;
}
-out:
+
diag_destroy(&ctx.diag);
trigger_clear(&on_replace);
- tuple_unref(key);
return rc;
}
diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c
index 53bc1d86..b1fcfabb 100644
--- a/src/box/vy_tx.c
+++ b/src/box/vy_tx.c
@@ -1056,21 +1056,17 @@ vy_tx_set_with_colmask(struct vy_tx *tx, struct vy_lsm *lsm,
return 0;
}
-int
+void
tx_manager_abort_writers(struct tx_manager *xm, struct vy_lsm *lsm)
{
- struct tuple *key = vy_stmt_new_select(lsm->env->key_format, NULL, 0);
- if (key == NULL)
- return -1;
struct vy_tx *tx;
rlist_foreach_entry(tx, &xm->writers, in_writers) {
assert(!vy_tx_is_ro(tx));
if (tx->state == VINYL_TX_READY &&
- write_set_search_key(&tx->write_set, lsm, key) != NULL)
+ write_set_search_key(&tx->write_set, lsm,
+ lsm->env->empty_key) != NULL)
tx->state = VINYL_TX_ABORT;
}
- tuple_unref(key);
- return 0;
}
void
diff --git a/src/box/vy_tx.h b/src/box/vy_tx.h
index 87066091..9524936f 100644
--- a/src/box/vy_tx.h
+++ b/src/box/vy_tx.h
@@ -277,10 +277,8 @@ tx_manager_mem_used(struct tx_manager *xm);
/**
* Abort all rw transactions that affect the given LSM tree
* and haven't reached WAL yet.
- *
- * Returns 0 on success, -1 on memory allocation error.
*/
-int
+void
tx_manager_abort_writers(struct tx_manager *xm, struct vy_lsm *lsm);
/** Initialize a tx object. */
--
2.11.0
next prev parent reply other threads:[~2019-02-21 10:26 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 10:26 [PATCH 00/12] vinyl: do not fill secondary tuples with nulls Vladimir Davydov
2019-02-21 10:26 ` Vladimir Davydov [this message]
2019-02-21 10:59 ` [tarantool-patches] Re: [PATCH 01/12] vinyl: use vy_lsm_env::empty_key where appropriate Konstantin Osipov
2019-02-21 10:26 ` [PATCH 02/12] vinyl: make vy_tuple_delete static Vladimir Davydov
2019-02-21 11:00 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 03/12] key_def: cleanup virtual function initialization Vladimir Davydov
2019-02-21 11:01 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 12:05 ` Vladimir Davydov
2019-02-21 10:26 ` [PATCH 04/12] key_def: move cmp and hash functions declarations to key_def.h Vladimir Davydov
2019-02-21 11:02 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 05/12] vinyl: move vy_tuple_key_contains_null to generic code Vladimir Davydov
2019-02-21 11:02 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 06/12] vinyl: move vy_key_dup " Vladimir Davydov
2019-02-21 11:04 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 11:52 ` Vladimir Davydov
2019-02-21 10:26 ` [PATCH 07/12] vinyl: sanitize full/empty key stmt detection Vladimir Davydov
2019-02-21 11:10 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 12:11 ` Vladimir Davydov
2019-03-01 12:57 ` Vladimir Davydov
2019-02-21 10:26 ` [PATCH 08/12] vinyl: remove optimized comparators Vladimir Davydov
2019-02-21 11:11 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 09/12] vinyl: introduce statement environment Vladimir Davydov
2019-02-21 11:14 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 10/12] vinyl: rename key stmt construction routine Vladimir Davydov
2019-02-21 11:15 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 12:14 ` Vladimir Davydov
2019-02-21 10:26 ` [PATCH 11/12] vinyl: don't use IPROTO_SELECT type for key statements Vladimir Davydov
2019-02-21 11:16 ` [tarantool-patches] " Konstantin Osipov
2019-02-21 10:26 ` [PATCH 12/12] vinyl: do not fill secondary tuples with nulls when decoded Vladimir Davydov
2019-02-21 15:39 ` [PATCH 00/12] vinyl: do not fill secondary tuples with nulls Vladimir Davydov
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=559411db1be54b5dcfcc40ee882275235c20dcd0.1550744027.git.vdavydov.dev@gmail.com \
--to=vdavydov.dev@gmail.com \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH 01/12] vinyl: use vy_lsm_env::empty_key where appropriate' \
/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