From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH 07/10] ddl: don't use txn_last_stmt on _collation commit/rollback
Date: Wed, 3 Jul 2019 22:30:09 +0300 [thread overview]
Message-ID: <06f836d47248228849ce7c2c372f2a1ebc83e8db.1562181197.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1562181197.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1562181197.git.vdavydov.dev@gmail.com>
When we implement transactional DDL, txn_last_stmt won't necessarily
point to the right statement on commit or rollback so we must avoid
using it.
---
src/box/alter.cc | 51 ++++++++++++++++++++++++---------------------------
1 file changed, 24 insertions(+), 27 deletions(-)
diff --git a/src/box/alter.cc b/src/box/alter.cc
index 4f046ef6..071258b7 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -2777,43 +2777,38 @@ coll_id_def_new_from_tuple(struct tuple *tuple, struct coll_id_def *def)
}
}
-/**
- * Rollback a change in collation space.
- * A change is only INSERT or DELETE, UPDATE is not supported.
- */
+/** Delete the new collation identifier. */
static void
-coll_id_cache_rollback(struct trigger *trigger, void *event)
+on_create_collation_rollback(struct trigger *trigger, void *event)
{
+ (void) event;
struct coll_id *coll_id = (struct coll_id *) trigger->data;
- struct txn_stmt *stmt = txn_last_stmt((struct txn*) event);
-
- if (stmt->new_tuple == NULL) {
- /* DELETE: put the collation identifier back. */
- assert(stmt->old_tuple != NULL);
- struct coll_id *replaced_id;
- if (coll_id_cache_replace(coll_id, &replaced_id) != 0) {
- panic("Out of memory on insertion into collation "\
- "cache");
- }
- assert(replaced_id == NULL);
- } else {
- /* INSERT: delete the new collation identifier. */
- assert(stmt->old_tuple == NULL);
- coll_id_cache_delete(coll_id);
- coll_id_delete(coll_id);
- }
+ coll_id_cache_delete(coll_id);
+ coll_id_delete(coll_id);
}
/** Free a deleted collation identifier on commit. */
static void
-coll_id_cache_commit(struct trigger *trigger, void *event)
+on_drop_collation_commit(struct trigger *trigger, void *event)
{
(void) event;
struct coll_id *coll_id = (struct coll_id *) trigger->data;
coll_id_delete(coll_id);
}
+/** Put the collation identifier back on rollback. */
+static void
+on_drop_collation_rollback(struct trigger *trigger, void *event)
+{
+ (void) event;
+ struct coll_id *coll_id = (struct coll_id *) trigger->data;
+ struct coll_id *replaced_id;
+ if (coll_id_cache_replace(coll_id, &replaced_id) != 0)
+ panic("Out of memory on insertion into collation cache");
+ assert(replaced_id == NULL);
+}
+
/**
* A trigger invoked on replace in a space containing
* collations that a user defined.
@@ -2826,12 +2821,12 @@ on_replace_dd_collation(struct trigger * /* trigger */, void *event)
struct tuple *old_tuple = stmt->old_tuple;
struct tuple *new_tuple = stmt->new_tuple;
txn_check_singlestatement_xc(txn, "Space _collation");
- struct trigger *on_rollback =
- txn_alter_trigger_new(coll_id_cache_rollback, NULL);
- struct trigger *on_commit =
- txn_alter_trigger_new(coll_id_cache_commit, NULL);
if (new_tuple == NULL && old_tuple != NULL) {
/* DELETE */
+ struct trigger *on_commit =
+ txn_alter_trigger_new(on_drop_collation_commit, NULL);
+ struct trigger *on_rollback =
+ txn_alter_trigger_new(on_drop_collation_rollback, NULL);
/*
* TODO: Check that no index uses the collation
* identifier.
@@ -2865,6 +2860,8 @@ on_replace_dd_collation(struct trigger * /* trigger */, void *event)
txn_on_commit(txn, on_commit);
} else if (new_tuple != NULL && old_tuple == NULL) {
/* INSERT */
+ struct trigger *on_rollback =
+ txn_alter_trigger_new(on_create_collation_rollback, NULL);
struct coll_id_def new_def;
coll_id_def_new_from_tuple(new_tuple, &new_def);
access_check_ddl(new_def.name, new_def.id, new_def.owner_id,
--
2.11.0
next prev parent reply other threads:[~2019-07-03 19:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-03 19:30 [PATCH 00/10] Prepare box/alter.cc for transactional DDL Vladimir Davydov
2019-07-03 19:30 ` [PATCH 01/10] ddl: unreference view on space drop synchronously Vladimir Davydov
2019-07-03 19:37 ` Konstantin Osipov
2019-07-03 19:30 ` [PATCH 02/10] ddl: synchronize user cache with actual data state Vladimir Davydov
2019-07-03 19:43 ` Konstantin Osipov
2019-07-03 20:00 ` Vladimir Davydov
2019-07-04 7:42 ` [tarantool-patches] " Konstantin Osipov
2019-07-03 19:30 ` [PATCH 03/10] ddl: synchronize func " Vladimir Davydov
2019-07-04 8:12 ` Konstantin Osipov
2019-07-03 19:30 ` [PATCH 04/10] ddl: synchronize sequence " Vladimir Davydov
2019-07-04 8:16 ` Konstantin Osipov
2019-07-03 19:30 ` [PATCH 05/10] ddl: fix _space_sequence rollback Vladimir Davydov
2019-07-03 19:30 ` [PATCH 06/10] ddl: restore sequence value if drop is rolled back Vladimir Davydov
2019-07-03 19:30 ` Vladimir Davydov [this message]
2019-07-03 19:30 ` [PATCH 08/10] ddl: don't use txn_last_stmt on _trigger commit/rollback Vladimir Davydov
2019-07-03 19:30 ` [PATCH 09/10] ddl: don't use txn_last_stmt on _ck_constraint commit/rollback Vladimir Davydov
2019-07-03 19:30 ` [PATCH 10/10] ddl: don't use txn_last_stmt on _cluster commit/rollback Vladimir Davydov
2019-07-04 15:01 ` [PATCH 00/10] Prepare box/alter.cc for transactional DDL 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=06f836d47248228849ce7c2c372f2a1ebc83e8db.1562181197.git.vdavydov.dev@gmail.com \
--to=vdavydov.dev@gmail.com \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH 07/10] ddl: don'\''t use txn_last_stmt on _collation commit/rollback' \
/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