Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH] schema: run on_alter_space triggers from space_cache_replace
@ 2019-03-27 13:30 Vladimir Davydov
  2019-03-27 13:31 ` Vladimir Davydov
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Davydov @ 2019-03-27 13:30 UTC (permalink / raw)
  To: tarantool-patches

We call it after each invocation of space_cache_replace() anyway.
Panic on error as space_cache_replace() isn't supposed to fail.
Remove empty on_create_space_commit() while we are at it.

Follow-up commit 082cffca4dba ("Synchronize lua schema update with
space cache").
---
 src/box/alter.cc  | 21 ---------------------
 src/box/schema.cc |  9 ++++++---
 2 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/src/box/alter.cc b/src/box/alter.cc
index 3fc31b8d..40b32eaf 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -786,8 +786,6 @@ alter_space_rollback(struct trigger *trigger, void * /* event */)
 	space_swap_triggers(alter->new_space, alter->old_space);
 	space_swap_fk_constraints(alter->new_space, alter->old_space);
 	space_cache_replace(alter->new_space, alter->old_space);
-	trigger_run(&on_alter_space, alter->old_space);
-
 	alter_space_delete(alter);
 }
 
@@ -889,8 +887,6 @@ alter_space_do(struct txn *txn, struct alter_space *alter)
 	 * cache with it.
 	 */
 	space_cache_replace(alter->old_space, alter->new_space);
-	trigger_run_xc(&on_alter_space, alter->new_space);
-
 	/*
 	 * Install transaction commit/rollback triggers to either
 	 * finish or rollback the DDL depending on the results of
@@ -1408,17 +1404,6 @@ on_drop_space_rollback(struct trigger *trigger, void *event)
 	(void) event;
 	struct space *space = (struct space *)trigger->data;
 	space_cache_replace(NULL, space);
-	trigger_run(&on_alter_space, space);
-}
-
-/**
- * Run the triggers registered on commit of a change in _space.
- */
-static void
-on_create_space_commit(struct trigger *trigger, void *event)
-{
-	(void) event;
-	(void) trigger;
 }
 
 /**
@@ -1434,7 +1419,6 @@ on_create_space_rollback(struct trigger *trigger, void *event)
 	(void) event;
 	struct space *space = (struct space *)trigger->data;
 	space_cache_replace(space, NULL);
-	trigger_run(&on_alter_space, space);
 	space_delete(space);
 }
 
@@ -1678,7 +1662,6 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event)
 		 * execution on a replica.
 		 */
 		space_cache_replace(NULL, space);
-		trigger_run_xc(&on_alter_space, space);
 		/*
 		 * Do not forget to update schema_version right after
 		 * inserting the space to the space_cache, since no
@@ -1694,9 +1677,6 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event)
 		 * so it's safe to simply drop the space on
 		 * rollback.
 		 */
-		struct trigger *on_commit =
-			txn_alter_trigger_new(on_create_space_commit, space);
-		txn_on_commit(txn, on_commit);
 		struct trigger *on_rollback =
 			txn_alter_trigger_new(on_create_space_rollback, space);
 		txn_on_rollback(txn, on_rollback);
@@ -1771,7 +1751,6 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event)
 		 * execution on a replica.
 		 */
 		space_cache_replace(old_space, NULL);
-		trigger_run_xc(&on_alter_space, old_space);
 		/*
 		 * Do not forget to update schema_version right after
 		 * deleting the space from the space_cache, since no
diff --git a/src/box/schema.cc b/src/box/schema.cc
index 74d70d8d..9e3f5561 100644
--- a/src/box/schema.cc
+++ b/src/box/schema.cc
@@ -251,6 +251,12 @@ space_cache_replace(struct space *old_space, struct space *new_space)
 		mh_strnptr_del(spaces_by_name, k, NULL);
 	}
 	space_cache_version++;
+
+	if (trigger_run(&on_alter_space, new_space != NULL ?
+					 new_space : old_space) != 0) {
+		diag_log();
+		panic("Can't update space cache");
+	}
 }
 
 /** A wrapper around space_new() for data dictionary spaces. */
@@ -301,8 +307,6 @@ sc_space_new(uint32_t id, const char *name,
 	 *   a snapshot of older version.
 	 */
 	init_system_space(space);
-
-	trigger_run_xc(&on_alter_space, space);
 }
 
 int
@@ -499,7 +503,6 @@ schema_init()
 		struct space *space = space_new_xc(def, &key_list);
 		space_cache_replace(NULL, space);
 		init_system_space(space);
-		trigger_run_xc(&on_alter_space, space);
 	}
 
 	/*
-- 
2.11.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-27 13:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-27 13:30 [PATCH] schema: run on_alter_space triggers from space_cache_replace Vladimir Davydov
2019-03-27 13:31 ` Vladimir Davydov

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