[RFC PATCH 08/23] vinyl: check key uniqueness before modifying tx write set
Konstantin Osipov
kostja at tarantool.org
Thu Aug 9 23:26:16 MSK 2018
* Vladimir Davydov <vdavydov.dev at gmail.com> [18/07/08 22:52]:
> + if (found != NULL && vy_tuple_compare(stmt, found,
> + lsm->pk->key_def) == 0) {
> + /*
> + * If the old and new tuples are the same in
> + * terms of the primary key definition, the
> + * statement doesn't modify the secondary key
> + * and so there's actually no conflict.
> + */
> + tuple_unref(found);
> + return 0;
> + }
In memtx, we pass old_tuple in txn_stmt around so that we can
check that found == old_tuple and ignore the duplicate (please
take a look at replace_check_dup). Why not do the same here, it
would save us a compare?
> +
> + /*
> + * For secondary indexes, uniqueness must be checked on both
> + * INSERT and REPLACE.
> + */
> + for (uint32_t i = 1; i < space->index_count; i++) {
> + struct vy_lsm *lsm = vy_lsm(space->index[i]);
> + if (vy_check_is_unique_secondary(env, tx, rv, space_name(space),
> + index_name_by_id(space, i),
> + lsm, stmt) != 0)
> + return -1;
> + }
> + return 0;
This code calls vy_get(), which in turns makes an unnecessary
lookup in the primary key.
--
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov
More information about the Tarantool-patches
mailing list