From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH 10/10] ddl: don't use txn_last_stmt on _cluster commit/rollback
Date: Wed, 3 Jul 2019 22:30:12 +0300 [thread overview]
Message-ID: <143733a60dc96d2c806ea0e82e7f86c1d6d584ea.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.
Note, replicas are still registered/unregisterd in the on_commit
trigger, but that's okay, as we don't really need _cluster space to
be in sync with the replica set.
---
src/box/alter.cc | 46 +++++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/src/box/alter.cc b/src/box/alter.cc
index dd66e46f..b470b763 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -3189,24 +3189,9 @@ on_replace_dd_schema(struct trigger * /* trigger */, void *event)
* with it.
*/
static void
-on_commit_dd_cluster(struct trigger *trigger, void *event)
+register_replica(struct trigger *trigger, void * /* event */)
{
- (void) trigger;
- struct txn_stmt *stmt = txn_last_stmt((struct txn *) event);
- struct tuple *new_tuple = stmt->new_tuple;
- struct tuple *old_tuple = stmt->old_tuple;
-
- if (new_tuple == NULL) {
- struct tt_uuid old_uuid;
- tuple_field_uuid_xc(stmt->old_tuple, BOX_CLUSTER_FIELD_UUID,
- &old_uuid);
- struct replica *replica = replica_by_uuid(&old_uuid);
- assert(replica != NULL);
- replica_clear_id(replica);
- return;
- } else if (old_tuple != NULL) {
- return; /* nothing to change */
- }
+ struct tuple *new_tuple = (struct tuple *)trigger->data;
uint32_t id = tuple_field_u32_xc(new_tuple, BOX_CLUSTER_FIELD_ID);
tt_uuid uuid;
@@ -3224,6 +3209,19 @@ on_commit_dd_cluster(struct trigger *trigger, void *event)
}
}
+static void
+unregister_replica(struct trigger *trigger, void * /* event */)
+{
+ struct tuple *old_tuple = (struct tuple *)trigger->data;
+
+ struct tt_uuid old_uuid;
+ tuple_field_uuid_xc(old_tuple, BOX_CLUSTER_FIELD_UUID, &old_uuid);
+
+ struct replica *replica = replica_by_uuid(&old_uuid);
+ assert(replica != NULL);
+ replica_clear_id(replica);
+}
+
/**
* A trigger invoked on replace in the space _cluster,
* which contains cluster configuration.
@@ -3276,6 +3274,11 @@ on_replace_dd_cluster(struct trigger *trigger, void *event)
"Space _cluster",
"updates of instance uuid");
}
+ } else {
+ struct trigger *on_commit;
+ on_commit = txn_alter_trigger_new(register_replica,
+ new_tuple);
+ txn_on_commit(txn, on_commit);
}
} else {
/*
@@ -3286,11 +3289,12 @@ on_replace_dd_cluster(struct trigger *trigger, void *event)
uint32_t replica_id =
tuple_field_u32_xc(old_tuple, BOX_CLUSTER_FIELD_ID);
replica_check_id(replica_id);
- }
- struct trigger *on_commit =
- txn_alter_trigger_new(on_commit_dd_cluster, NULL);
- txn_on_commit(txn, on_commit);
+ struct trigger *on_commit;
+ on_commit = txn_alter_trigger_new(unregister_replica,
+ old_tuple);
+ txn_on_commit(txn, on_commit);
+ }
}
/* }}} cluster configuration */
--
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 ` [PATCH 07/10] ddl: don't use txn_last_stmt on _collation commit/rollback Vladimir Davydov
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 ` Vladimir Davydov [this message]
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=143733a60dc96d2c806ea0e82e7f86c1d6d584ea.1562181197.git.vdavydov.dev@gmail.com \
--to=vdavydov.dev@gmail.com \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH 10/10] ddl: don'\''t use txn_last_stmt on _cluster 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