Tarantool development patches archive
 help / color / mirror / Atom feed
From: Ilya Kosarev <i.kosarev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: georgy@tarantool.org, i.kosarev@corp.mail.ru,
	Ilya Kosarev <i.kosarev@tarantool.org>
Subject: [tarantool-patches] [PATCH v3 1/5] refactoring: remove exceptions from triggers except alter.cc
Date: Wed, 11 Sep 2019 16:05:15 +0300	[thread overview]
Message-ID: <4b38ca3cc5774e669aa74b6fae9a25a8b09a4365.1568206816.git.i.kosarev@tarantool.org> (raw)
In-Reply-To: <cover.1568206816.git.i.kosarev@tarantool.org>
In-Reply-To: <cover.1568206816.git.i.kosarev@tarantool.org>

Triggers' signatures are updated so that they will be able
to return error codes instead of throwing exceptions.
In files except alter.cc triggers don't throw exceptions any more.
---
 src/box/alter.cc            | 182 ++++++++++++++++++++++++------------
 src/box/applier.cc          |  18 ++--
 src/box/ck_constraint.c     |   9 +-
 src/box/ck_constraint.h     |   2 +-
 src/box/iproto.cc           |   3 +-
 src/box/lua/call.c          |   5 +-
 src/box/lua/sequence.c      |   3 +-
 src/box/lua/space.cc        |   3 +-
 src/box/memtx_space.c       |  17 ++--
 src/box/relay.cc            |   5 +-
 src/box/replication.cc      |  22 +++--
 src/box/session.cc          |   3 +-
 src/box/txn.c               |  10 +-
 src/box/vinyl.c             |  44 +++++----
 src/box/vy_scheduler.c      |   3 +-
 src/lib/core/fiber.c        |   3 +-
 src/lib/core/trigger.cc     |  18 ++--
 src/lib/core/trigger.h      |   2 +-
 src/lua/trigger.c           |   7 +-
 src/main.cc                 |   3 +-
 test/unit/cbus.c            |   3 +-
 test/unit/swim.c            |   6 +-
 test/unit/swim_test_utils.c |   3 +-
 23 files changed, 235 insertions(+), 139 deletions(-)

diff --git a/src/box/alter.cc b/src/box/alter.cc
index c0780d6da..522b1b596 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -858,7 +858,7 @@ struct mh_i32_t *AlterSpaceLock::registry;
  * of the dropped indexes.
  * Replace the old space with a new one in the space cache.
  */
-static void
+static int
 alter_space_commit(struct trigger *trigger, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -888,6 +888,7 @@ alter_space_commit(struct trigger *trigger, void *event)
 	space_delete(alter->old_space);
 	alter->old_space = NULL;
 	alter_space_delete(alter);
+	return 0;
 }
 
 /**
@@ -898,7 +899,7 @@ alter_space_commit(struct trigger *trigger, void *event)
  * Keep in mind that we may end up here in case of
  * alter_space_commit() failure (unlikely)
  */
-static void
+static int
 alter_space_rollback(struct trigger *trigger, void * /* event */)
 {
 	struct alter_space *alter = (struct alter_space *) trigger->data;
@@ -917,6 +918,7 @@ alter_space_rollback(struct trigger *trigger, void * /* event */)
 	space_swap_fk_constraints(alter->new_space, alter->old_space);
 	space_cache_replace(alter->new_space, alter->old_space);
 	alter_space_delete(alter);
+	return 0;
 }
 
 /**
@@ -1644,12 +1646,13 @@ MoveCkConstraints::rollback(struct alter_space *alter)
 /**
  * Delete the space. It is already removed from the space cache.
  */
-static void
+static int
 on_drop_space_commit(struct trigger *trigger, void *event)
 {
 	(void) event;
 	struct space *space = (struct space *)trigger->data;
 	space_delete(space);
+	return 0;
 }
 
 /**
@@ -1657,12 +1660,13 @@ on_drop_space_commit(struct trigger *trigger, void *event)
  * of all other events happened after the space was removed were
  * reverted by the cascading rollback.
  */
-static void
+static int
 on_drop_space_rollback(struct trigger *trigger, void *event)
 {
 	(void) event;
 	struct space *space = (struct space *)trigger->data;
 	space_cache_replace(NULL, space);
+	return 0;
 }
 
 /**
@@ -1672,13 +1676,14 @@ on_drop_space_rollback(struct trigger *trigger, void *event)
  * By the time the space is removed, it should be empty: we
  * rely on cascading rollback.
  */
-static void
+static int
 on_create_space_rollback(struct trigger *trigger, void *event)
 {
 	(void) event;
 	struct space *space = (struct space *)trigger->data;
 	space_cache_replace(space, NULL);
 	space_delete(space);
+	return 0;
 }
 
 /**
@@ -1780,12 +1785,13 @@ update_view_references(struct Select *select, int update_value,
  * Trigger which is fired to commit creation of new SQL view.
  * Its purpose is to release memory of SELECT.
  */
-static void
+static int
 on_create_view_commit(struct trigger *trigger, void *event)
 {
 	(void) event;
 	struct Select *select = (struct Select *)trigger->data;
 	sql_select_delete(sql_get(), select);
+	return 0;
 }
 
 /**
@@ -1793,13 +1799,14 @@ on_create_view_commit(struct trigger *trigger, void *event)
  * Decrements view reference counters of dependent spaces and
  * releases memory for SELECT.
  */
-static void
+static int
 on_create_view_rollback(struct trigger *trigger, void *event)
 {
 	(void) event;
 	struct Select *select = (struct Select *)trigger->data;
 	update_view_references(select, -1, true, NULL);
 	sql_select_delete(sql_get(), select);
+	return 0;
 }
 
 /**
@@ -1807,12 +1814,13 @@ on_create_view_rollback(struct trigger *trigger, void *event)
  * Its purpose is to decrement view reference counters of
  * dependent spaces and release memory for SELECT.
  */
-static void
+static int
 on_drop_view_commit(struct trigger *trigger, void *event)
 {
 	(void) event;
 	struct Select *select = (struct Select *)trigger->data;
 	sql_select_delete(sql_get(), select);
+	return 0;
 }
 
 /**
@@ -1820,13 +1828,14 @@ on_drop_view_commit(struct trigger *trigger, void *event)
  * Release memory for struct SELECT compiled in
  * on_replace_dd_space trigger.
  */
-static void
+static int
 on_drop_view_rollback(struct trigger *trigger, void *event)
 {
 	(void) event;
 	struct Select *select = (struct Select *)trigger->data;
 	update_view_references(select, 1, true, NULL);
 	sql_select_delete(sql_get(), select);
+	return 0;
 }
 
 /**
@@ -1879,7 +1888,7 @@ on_drop_view_rollback(struct trigger *trigger, void *event)
  * dynamic space configuration such a check would be particularly
  * clumsy, so it is simply not done.
  */
-static void
+static int
 on_replace_dd_space(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -2115,6 +2124,7 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event)
 		alter_space_do(stmt, alter);
 		alter_guard.is_active = false;
 	}
+	return 0;
 }
 
 /**
@@ -2175,7 +2185,7 @@ index_is_used_by_fk_constraint(struct rlist *fk_list, uint32_t iid)
  *   for offsets is relinquished to the slab allocator as tuples
  *   are modified.
  */
-static void
+static int
 on_replace_dd_index(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -2352,6 +2362,7 @@ on_replace_dd_index(struct trigger * /* trigger */, void *event)
 	(void) new UpdateSchemaVersion(alter);
 	alter_space_do(stmt, alter);
 	scoped_guard.is_active = false;
+	return 0;
 }
 
 /**
@@ -2365,7 +2376,7 @@ on_replace_dd_index(struct trigger * /* trigger */, void *event)
  * This is OK, because a WAL write error implies cascading
  * rollback of all transactions following this one.
  */
-static void
+static int
 on_replace_dd_truncate(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -2374,7 +2385,7 @@ on_replace_dd_truncate(struct trigger * /* trigger */, void *event)
 
 	if (new_tuple == NULL) {
 		/* Space drop - nothing to do. */
-		return;
+		return 0;
 	}
 
 	uint32_t space_id =
@@ -2386,7 +2397,7 @@ on_replace_dd_truncate(struct trigger * /* trigger */, void *event)
 		 * Space creation during initial recovery -
 		 * nothing to do.
 		 */
-		return;
+		return 0;
 	}
 
 	/*
@@ -2428,6 +2439,7 @@ on_replace_dd_truncate(struct trigger * /* trigger */, void *event)
 	(void) new MoveCkConstraints(alter);
 	alter_space_do(stmt, alter);
 	scoped_guard.is_active = false;
+	return 0;
 }
 
 /* {{{ access control */
@@ -2572,15 +2584,16 @@ user_def_new_from_tuple(struct tuple *tuple)
 	return user;
 }
 
-static void
+static int
 user_cache_remove_user(struct trigger *trigger, void * /* event */)
 {
 	struct tuple *tuple = (struct tuple *)trigger->data;
 	uint32_t uid = tuple_field_u32_xc(tuple, BOX_USER_FIELD_ID);
 	user_cache_delete(uid);
+	return 0;
 }
 
-static void
+static int
 user_cache_alter_user(struct trigger *trigger, void * /* event */)
 {
 	struct tuple *tuple = (struct tuple *)trigger->data;
@@ -2589,12 +2602,13 @@ user_cache_alter_user(struct trigger *trigger, void * /* event */)
 	/* Can throw if, e.g. too many users. */
 	user_cache_replace(user);
 	def_guard.is_active = false;
+	return 0;
 }
 
 /**
  * A trigger invoked on replace in the user table.
  */
-static void
+static int
 on_replace_dd_user(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -2654,6 +2668,7 @@ on_replace_dd_user(struct trigger * /* trigger */, void *event)
 			txn_alter_trigger_new(user_cache_alter_user, old_tuple);
 		txn_stmt_on_rollback(stmt, on_rollback);
 	}
+	return 0;
 }
 
 /**
@@ -2848,7 +2863,7 @@ func_def_new_from_tuple(struct tuple *tuple)
 	return def;
 }
 
-static void
+static int
 on_create_func_rollback(struct trigger *trigger, void * /* event */)
 {
 	/* Remove the new function from the cache and delete it. */
@@ -2856,30 +2871,33 @@ on_create_func_rollback(struct trigger *trigger, void * /* event */)
 	func_cache_delete(func->def->fid);
 	trigger_run_xc(&on_alter_func, func);
 	func_delete(func);
+	return 0;
 }
 
-static void
+static int
 on_drop_func_commit(struct trigger *trigger, void * /* event */)
 {
 	/* Delete the old function. */
 	struct func *func = (struct func *)trigger->data;
 	func_delete(func);
+	return 0;
 }
 
-static void
+static int
 on_drop_func_rollback(struct trigger *trigger, void * /* event */)
 {
 	/* Insert the old function back into the cache. */
 	struct func *func = (struct func *)trigger->data;
 	func_cache_insert(func);
 	trigger_run_xc(&on_alter_func, func);
+	return 0;
 }
 
 /**
  * A trigger invoked on replace in a space containing
  * functions on which there were defined any grants.
  */
-static void
+static int
 on_replace_dd_func(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -2958,6 +2976,7 @@ on_replace_dd_func(struct trigger * /* trigger */, void *event)
 				  "alter");
 		}
 	}
+	return 0;
 }
 
 /** Create a collation identifier definition from tuple. */
@@ -3046,27 +3065,29 @@ coll_id_def_new_from_tuple(struct tuple *tuple, struct coll_id_def *def)
 }
 
 /** Delete the new collation identifier. */
-static void
+static int
 on_create_collation_rollback(struct trigger *trigger, void *event)
 {
 	(void) event;
 	struct coll_id *coll_id = (struct coll_id *) trigger->data;
 	coll_id_cache_delete(coll_id);
 	coll_id_delete(coll_id);
+	return 0;
 }
 
 
 /** Free a deleted collation identifier on commit. */
-static void
+static int
 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);
+	return 0;
 }
 
 /** Put the collation identifier back on rollback. */
-static void
+static int
 on_drop_collation_rollback(struct trigger *trigger, void *event)
 {
 	(void) event;
@@ -3075,13 +3096,14 @@ on_drop_collation_rollback(struct trigger *trigger, void *event)
 	if (coll_id_cache_replace(coll_id, &replaced_id) != 0)
 		panic("Out of memory on insertion into collation cache");
 	assert(replaced_id == NULL);
+	return 0;
 }
 
 /**
  * A trigger invoked on replace in a space containing
  * collations that a user defined.
  */
-static void
+static int
 on_replace_dd_collation(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -3149,6 +3171,7 @@ on_replace_dd_collation(struct trigger * /* trigger */, void *event)
 		assert(new_tuple != NULL && old_tuple != NULL);
 		tnt_raise(ClientError, ER_UNSUPPORTED, "collation", "alter");
 	}
+	return 0;
 }
 
 /**
@@ -3355,7 +3378,7 @@ grant_or_revoke(struct priv_def *priv)
 }
 
 /** A trigger called on rollback of grant. */
-static void
+static int
 revoke_priv(struct trigger *trigger, void *event)
 {
 	(void) event;
@@ -3364,10 +3387,11 @@ revoke_priv(struct trigger *trigger, void *event)
 	priv_def_create_from_tuple(&priv, tuple);
 	priv.access = 0;
 	grant_or_revoke(&priv);
+	return 0;
 }
 
 /** A trigger called on rollback of revoke or modify. */
-static void
+static int
 modify_priv(struct trigger *trigger, void *event)
 {
 	(void) event;
@@ -3375,13 +3399,14 @@ modify_priv(struct trigger *trigger, void *event)
 	struct priv_def priv;
 	priv_def_create_from_tuple(&priv, tuple);
 	grant_or_revoke(&priv);
+	return 0;
 }
 
 /**
  * A trigger invoked on replace in the space containing
  * all granted privileges.
  */
-static void
+static int
 on_replace_dd_priv(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -3414,6 +3439,7 @@ on_replace_dd_priv(struct trigger * /* trigger */, void *event)
 			txn_alter_trigger_new(modify_priv, old_tuple);
 		txn_stmt_on_rollback(stmt, on_rollback);
 	}
+	return 0;
 }
 
 /* }}} access control */
@@ -3429,7 +3455,7 @@ on_replace_dd_priv(struct trigger * /* trigger */, void *event)
  * concern us, we can safely change the cluster id in before-replace
  * event, not in after-replace event.
  */
-static void
+static int
 on_replace_dd_schema(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -3446,6 +3472,7 @@ on_replace_dd_schema(struct trigger * /* trigger */, void *event)
 		REPLICASET_UUID = uu;
 		say_info("cluster uuid %s", tt_uuid_str(&uu));
 	}
+	return 0;
 }
 
 /**
@@ -3453,7 +3480,7 @@ on_replace_dd_schema(struct trigger * /* trigger */, void *event)
  * write ahead log. Update the cluster configuration cache
  * with it.
  */
-static void
+static int
 register_replica(struct trigger *trigger, void * /* event */)
 {
 	struct tuple *new_tuple = (struct tuple *)trigger->data;
@@ -3472,9 +3499,10 @@ register_replica(struct trigger *trigger, void * /* event */)
 			panic("Can't register replica: %s", e->errmsg);
 		}
 	}
+	return 0;
 }
 
-static void
+static int
 unregister_replica(struct trigger *trigger, void * /* event */)
 {
 	struct tuple *old_tuple = (struct tuple *)trigger->data;
@@ -3485,6 +3513,7 @@ unregister_replica(struct trigger *trigger, void * /* event */)
 	struct replica *replica = replica_by_uuid(&old_uuid);
 	assert(replica != NULL);
 	replica_clear_id(replica);
+	return 0;
 }
 
 /**
@@ -3505,7 +3534,7 @@ unregister_replica(struct trigger *trigger, void * /* event */)
  * replica set can not by mistake join/follow another replica
  * set without first being reset (emptied).
  */
-static void
+static int
 on_replace_dd_cluster(struct trigger *trigger, void *event)
 {
 	(void) trigger;
@@ -3559,6 +3588,7 @@ on_replace_dd_cluster(struct trigger *trigger, void *event)
 						  old_tuple);
 		txn_stmt_on_commit(stmt, on_commit);
 	}
+	return 0;
 }
 
 /* }}} cluster configuration */
@@ -3606,7 +3636,7 @@ sequence_def_new_from_tuple(struct tuple *tuple, uint32_t errcode)
 	return def;
 }
 
-static void
+static int
 on_create_sequence_rollback(struct trigger *trigger, void * /* event */)
 {
 	/* Remove the new sequence from the cache and delete it. */
@@ -3614,35 +3644,39 @@ on_create_sequence_rollback(struct trigger *trigger, void * /* event */)
 	sequence_cache_delete(seq->def->id);
 	trigger_run_xc(&on_alter_sequence, seq);
 	sequence_delete(seq);
+	return 0;
 }
 
-static void
+static int
 on_drop_sequence_commit(struct trigger *trigger, void * /* event */)
 {
 	/* Delete the old sequence. */
 	struct sequence *seq = (struct sequence *)trigger->data;
 	sequence_delete(seq);
+	return 0;
 }
 
-static void
+static int
 on_drop_sequence_rollback(struct trigger *trigger, void * /* event */)
 {
 	/* Insert the old sequence back into the cache. */
 	struct sequence *seq = (struct sequence *)trigger->data;
 	sequence_cache_insert(seq);
 	trigger_run_xc(&on_alter_sequence, seq);
+	return 0;
 }
 
 
-static void
+static int
 on_alter_sequence_commit(struct trigger *trigger, void * /* event */)
 {
 	/* Delete the old old sequence definition. */
 	struct sequence_def *def = (struct sequence_def *)trigger->data;
 	free(def);
+	return 0;
 }
 
-static void
+static int
 on_alter_sequence_rollback(struct trigger *trigger, void * /* event */)
 {
 	/* Restore the old sequence definition. */
@@ -3652,13 +3686,14 @@ on_alter_sequence_rollback(struct trigger *trigger, void * /* event */)
 	free(seq->def);
 	seq->def = def;
 	trigger_run_xc(&on_alter_sequence, seq);
+	return 0;
 }
 
 /**
  * A trigger invoked on replace in space _sequence.
  * Used to alter a sequence definition.
  */
-static void
+static int
 on_replace_dd_sequence(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -3722,10 +3757,11 @@ on_replace_dd_sequence(struct trigger * /* trigger */, void *event)
 
 	def_guard.is_active = false;
 	trigger_run_xc(&on_alter_sequence, seq);
+	return 0;
 }
 
 /** Restore the old sequence value on rollback. */
-static void
+static int
 on_drop_sequence_data_rollback(struct trigger *trigger, void * /* event */)
 {
 	struct tuple *tuple = (struct tuple *)trigger->data;
@@ -3736,13 +3772,14 @@ on_drop_sequence_data_rollback(struct trigger *trigger, void * /* event */)
 	assert(seq != NULL);
 	if (sequence_set(seq, val) != 0)
 		panic("Can't restore sequence value");
+	return 0;
 }
 
 /**
  * A trigger invoked on replace in space _sequence_data.
  * Used to update a sequence value.
  */
-static void
+static int
 on_replace_dd_sequence_data(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -3773,6 +3810,7 @@ on_replace_dd_sequence_data(struct trigger * /* trigger */, void *event)
 		txn_stmt_on_rollback(stmt, on_rollback);
 		sequence_reset(seq);
 	}
+	return 0;
 }
 
 /**
@@ -3814,7 +3852,7 @@ sequence_field_from_tuple(struct space *space, struct tuple *tuple,
 }
 
 /** Attach a sequence to a space on rollback in _space_sequence. */
-static void
+static int
 set_space_sequence(struct trigger *trigger, void * /* event */)
 {
 	struct tuple *tuple = (struct tuple *)trigger->data;
@@ -3836,10 +3874,11 @@ set_space_sequence(struct trigger *trigger, void * /* event */)
 	free(space->sequence_path);
 	space->sequence_path = path;
 	trigger_run_xc(&on_alter_space, space);
+	return 0;
 }
 
 /** Detach a sequence from a space on rollback in _space_sequence. */
-static void
+static int
 clear_space_sequence(struct trigger *trigger, void * /* event */)
 {
 	struct tuple *tuple = (struct tuple *)trigger->data;
@@ -3854,13 +3893,14 @@ clear_space_sequence(struct trigger *trigger, void * /* event */)
 	free(space->sequence_path);
 	space->sequence_path = NULL;
 	trigger_run_xc(&on_alter_space, space);
+	return 0;
 }
 
 /**
  * A trigger invoked on replace in space _space_sequence.
  * Used to update space <-> sequence mapping.
  */
-static void
+static int
 on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -3939,12 +3979,13 @@ on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event)
 		txn_stmt_on_rollback(stmt, on_rollback);
 	}
 	trigger_run_xc(&on_alter_space, space);
+	return 0;
 }
 
 /* }}} sequence */
 
 /** Delete the new trigger on rollback of an INSERT statement. */
-static void
+static int
 on_create_trigger_rollback(struct trigger *trigger, void * /* event */)
 {
 	struct sql_trigger *old_trigger = (struct sql_trigger *)trigger->data;
@@ -3956,28 +3997,30 @@ on_create_trigger_rollback(struct trigger *trigger, void * /* event */)
 	assert(rc == 0);
 	assert(new_trigger == old_trigger);
 	sql_trigger_delete(sql_get(), new_trigger);
+	return 0;
 }
 
 /** Restore the old trigger on rollback of a DELETE statement. */
-static void
+static int
 on_drop_trigger_rollback(struct trigger *trigger, void * /* event */)
 {
 	struct sql_trigger *old_trigger = (struct sql_trigger *)trigger->data;
 	struct sql_trigger *new_trigger;
 	if (old_trigger == NULL)
-		return;
+		return 0;
 	if (sql_trigger_replace(sql_trigger_name(old_trigger),
 				sql_trigger_space_id(old_trigger),
 				old_trigger, &new_trigger) != 0)
 		panic("Out of memory on insertion into trigger hash");
 	assert(new_trigger == NULL);
+	return 0;
 }
 
 /**
  * Restore the old trigger and delete the new trigger on rollback
  * of a REPLACE statement.
  */
-static void
+static int
 on_replace_trigger_rollback(struct trigger *trigger, void * /* event */)
 {
 	struct sql_trigger *old_trigger = (struct sql_trigger *)trigger->data;
@@ -3987,24 +4030,26 @@ on_replace_trigger_rollback(struct trigger *trigger, void * /* event */)
 				old_trigger, &new_trigger) != 0)
 		panic("Out of memory on insertion into trigger hash");
 	sql_trigger_delete(sql_get(), new_trigger);
+	return 0;
 }
 
 /**
  * Trigger invoked on commit in the _trigger space.
  * Drop useless old sql_trigger AST object if any.
  */
-static void
+static int
 on_replace_trigger_commit(struct trigger *trigger, void * /* event */)
 {
 	struct sql_trigger *old_trigger = (struct sql_trigger *)trigger->data;
 	sql_trigger_delete(sql_get(), old_trigger);
+	return 0;
 }
 
 /**
  * A trigger invoked on replace in a space containing
  * SQL triggers.
  */
-static void
+static int
 on_replace_dd_trigger(struct trigger * /* trigger */, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -4099,6 +4144,7 @@ on_replace_dd_trigger(struct trigger * /* trigger */, void *event)
 
 	txn_stmt_on_rollback(stmt, on_rollback);
 	txn_stmt_on_commit(stmt, on_commit);
+	return 0;
 }
 
 /**
@@ -4292,7 +4338,7 @@ space_reset_fk_constraint_mask(struct space *space)
  * from parent's and child's lists of constraints and
  * release memory.
  */
-static void
+static int
 on_create_fk_constraint_rollback(struct trigger *trigger, void *event)
 {
 	(void) event;
@@ -4302,10 +4348,11 @@ on_create_fk_constraint_rollback(struct trigger *trigger, void *event)
 	space_reset_fk_constraint_mask(space_by_id(fk->def->parent_id));
 	space_reset_fk_constraint_mask(space_by_id(fk->def->child_id));
 	fk_constraint_delete(fk);
+	return 0;
 }
 
 /** Return old FK and release memory for the new one. */
-static void
+static int
 on_replace_fk_constraint_rollback(struct trigger *trigger, void *event)
 {
 	(void) event;
@@ -4320,10 +4367,11 @@ on_replace_fk_constraint_rollback(struct trigger *trigger, void *event)
 	rlist_add_entry(&parent->parent_fk_constraint, old_fk, in_parent_space);
 	space_reset_fk_constraint_mask(parent);
 	space_reset_fk_constraint_mask(child);
+	return 0;
 }
 
 /** On rollback of drop simply return back FK to DD. */
-static void
+static int
 on_drop_fk_constraint_rollback(struct trigger *trigger, void *event)
 {
 	(void) event;
@@ -4336,6 +4384,7 @@ on_drop_fk_constraint_rollback(struct trigger *trigger, void *event)
 			       FIELD_LINK_CHILD);
 	fk_constraint_set_mask(old_fk, &parent->fk_constraint_mask,
 			       FIELD_LINK_PARENT);
+	return 0;
 }
 
 /**
@@ -4343,11 +4392,12 @@ on_drop_fk_constraint_rollback(struct trigger *trigger, void *event)
  * foreign key entry from both (parent's and child's) lists,
  * so just release memory.
  */
-static void
+static int
 on_drop_or_replace_fk_constraint_commit(struct trigger *trigger, void *event)
 {
 	(void) event;
 	fk_constraint_delete((struct fk_constraint *) trigger->data);
+	return 0;
 }
 
 /**
@@ -4386,7 +4436,7 @@ error:
 }
 
 /** A trigger invoked on replace in the _fk_constraint space. */
-static void
+static int
 on_replace_dd_fk_constraint(struct trigger * /* trigger*/, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -4554,6 +4604,7 @@ on_replace_dd_fk_constraint(struct trigger * /* trigger*/, void *event)
 		space_reset_fk_constraint_mask(child_space);
 		space_reset_fk_constraint_mask(parent_space);
 	}
+	return 0;
 }
 
 /** Create an instance of check constraint definition by tuple. */
@@ -4593,7 +4644,7 @@ ck_constraint_def_new_from_tuple(struct tuple *tuple)
 }
 
 /** Rollback INSERT check constraint. */
-static void
+static int
 on_create_ck_constraint_rollback(struct trigger *trigger, void * /* event */)
 {
 	struct ck_constraint *ck = (struct ck_constraint *)trigger->data;
@@ -4605,19 +4656,21 @@ on_create_ck_constraint_rollback(struct trigger *trigger, void * /* event */)
 	space_remove_ck_constraint(space, ck);
 	ck_constraint_delete(ck);
 	trigger_run_xc(&on_alter_space, space);
+	return 0;
 }
 
 /** Commit DELETE check constraint. */
-static void
+static int
 on_drop_ck_constraint_commit(struct trigger *trigger, void * /* event */)
 {
 	struct ck_constraint *ck = (struct ck_constraint *)trigger->data;
 	assert(ck != NULL);
 	ck_constraint_delete(ck);
+	return 0;
 }
 
 /** Rollback DELETE check constraint. */
-static void
+static int
 on_drop_ck_constraint_rollback(struct trigger *trigger, void * /* event */)
 {
 	struct ck_constraint *ck = (struct ck_constraint *)trigger->data;
@@ -4629,19 +4682,21 @@ on_drop_ck_constraint_rollback(struct trigger *trigger, void * /* event */)
 	if (space_add_ck_constraint(space, ck) != 0)
 		panic("Can't recover after CK constraint drop rollback");
 	trigger_run_xc(&on_alter_space, space);
+	return 0;
 }
 
 /** Commit REPLACE check constraint. */
-static void
+static int
 on_replace_ck_constraint_commit(struct trigger *trigger, void * /* event */)
 {
 	struct ck_constraint *ck = (struct ck_constraint *)trigger->data;
 	if (ck != NULL)
 		ck_constraint_delete(ck);
+	return 0;
 }
 
 /** Rollback REPLACE check constraint. */
-static void
+static int
 on_replace_ck_constraint_rollback(struct trigger *trigger, void * /* event */)
 {
 	struct ck_constraint *ck = (struct ck_constraint *)trigger->data;
@@ -4655,10 +4710,11 @@ on_replace_ck_constraint_rollback(struct trigger *trigger, void * /* event */)
 	rlist_add_entry(&space->ck_constraint, ck, link);
 	ck_constraint_delete(new_ck);
 	trigger_run_xc(&on_alter_space, space);
+	return 0;
 }
 
 /** A trigger invoked on replace in the _ck_constraint space. */
-static void
+static int
 on_replace_dd_ck_constraint(struct trigger * /* trigger*/, void *event)
 {
 	struct txn *txn = (struct txn *) event;
@@ -4743,10 +4799,11 @@ on_replace_dd_ck_constraint(struct trigger * /* trigger*/, void *event)
 	txn_stmt_on_commit(stmt, on_commit);
 
 	trigger_run_xc(&on_alter_space, space);
+	return 0;
 }
 
 /** A trigger invoked on replace in the _func_index space. */
-static void
+static int
 on_replace_dd_func_index(struct trigger *trigger, void *event)
 {
 	(void) trigger;
@@ -4794,7 +4851,7 @@ on_replace_dd_func_index(struct trigger *trigger, void *event)
 	 * function. Index rebuild is not required.
 	 */
 	if (index_def_get_func(index->def) == func)
-		return;
+		return 0;
 
 	alter = alter_space_new(space);
 	auto scoped_guard = make_scoped_guard([=] {alter_space_delete(alter);});
@@ -4807,6 +4864,7 @@ on_replace_dd_func_index(struct trigger *trigger, void *event)
 	alter_space_do(stmt, alter);
 
 	scoped_guard.is_active = false;
+	return 0;
 }
 
 struct trigger alter_space_on_replace_space = {
diff --git a/src/box/applier.cc b/src/box/applier.cc
index 6239fcfd3..14cd1f6b6 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -611,7 +611,7 @@ applier_read_tx(struct applier *applier, struct stailq *rows)
 				    next)->row.is_commit);
 }
 
-static void
+static int
 applier_txn_rollback_cb(struct trigger *trigger, void *event)
 {
 	(void) trigger;
@@ -622,14 +622,16 @@ applier_txn_rollback_cb(struct trigger *trigger, void *event)
 	trigger_run(&replicaset.applier.on_rollback, event);
 	/* Rollback applier vclock to the committed one. */
 	vclock_copy(&replicaset.applier.vclock, &replicaset.vclock);
+	return 0;
 }
 
-static void
+static int
 applier_txn_commit_cb(struct trigger *trigger, void *event)
 {
 	(void) trigger;
 	/* Broadcast the commit event across all appliers. */
 	trigger_run(&replicaset.applier.on_commit, event);
+	return 0;
 }
 
 /**
@@ -745,18 +747,19 @@ fail:
 /*
  * A trigger to update an applier state after a replication commit.
  */
-static void
+static int
 applier_on_commit(struct trigger *trigger, void *event)
 {
 	(void) event;
 	struct applier *applier = (struct applier *)trigger->data;
 	fiber_cond_signal(&applier->writer_cond);
+	return 0;
 }
 
 /*
  * A trigger to update an applier state after a replication rollback.
  */
-static void
+static int
 applier_on_rollback(struct trigger *trigger, void *event)
 {
 	(void) event;
@@ -768,6 +771,7 @@ applier_on_rollback(struct trigger *trigger, void *event)
 	}
 	/* Stop the applier fiber. */
 	fiber_cancel(applier->reader);
+	return 0;
 }
 
 /**
@@ -1131,7 +1135,7 @@ struct applier_on_state {
 	struct fiber_cond wakeup;
 };
 
-static void
+static int
 applier_on_state_f(struct trigger *trigger, void *event)
 {
 	(void) event;
@@ -1143,12 +1147,14 @@ applier_on_state_f(struct trigger *trigger, void *event)
 	if (applier->state != APPLIER_OFF &&
 	    applier->state != APPLIER_STOPPED &&
 	    applier->state != on_state->desired_state)
-		return;
+		return 0;
 
 	/* Wake up waiter */
 	fiber_cond_signal(&on_state->wakeup);
 
 	applier_pause(applier);
+
+	return 0;
 }
 
 static inline void
diff --git a/src/box/ck_constraint.c b/src/box/ck_constraint.c
index 1cde27022..2e0fa24a5 100644
--- a/src/box/ck_constraint.c
+++ b/src/box/ck_constraint.c
@@ -175,7 +175,7 @@ ck_constraint_program_run(struct ck_constraint *ck_constraint,
 	return sql_reset(ck_constraint->stmt);
 }
 
-void
+int
 ck_constraint_on_replace_trigger(struct trigger *trigger, void *event)
 {
 	(void) trigger;
@@ -184,7 +184,7 @@ ck_constraint_on_replace_trigger(struct trigger *trigger, void *event)
 	assert(stmt != NULL);
 	struct tuple *new_tuple = stmt->new_tuple;
 	if (new_tuple == NULL)
-		return;
+		return 0;
 
 	struct space *space = stmt->space;
 	assert(space != NULL);
@@ -195,15 +195,16 @@ ck_constraint_on_replace_trigger(struct trigger *trigger, void *event)
 	if (field_ref == NULL) {
 		diag_set(OutOfMemory, field_ref_sz, "region_alloc",
 			 "field_ref");
-		diag_raise();
+		return -1;
 	}
 	vdbe_field_ref_prepare_tuple(field_ref, new_tuple);
 
 	struct ck_constraint *ck_constraint;
 	rlist_foreach_entry(ck_constraint, &space->ck_constraint, link) {
 		if (ck_constraint_program_run(ck_constraint, field_ref) != 0)
-			diag_raise();
+			return -1;
 	}
+	return 0;
 }
 
 struct ck_constraint *
diff --git a/src/box/ck_constraint.h b/src/box/ck_constraint.h
index f26f77a38..6af82afe6 100644
--- a/src/box/ck_constraint.h
+++ b/src/box/ck_constraint.h
@@ -198,7 +198,7 @@ ck_constraint_delete(struct ck_constraint *ck_constraint);
  * Raises an exception when some ck constraint is unsatisfied.
  * The diag message is set.
  */
-void
+int
 ck_constraint_on_replace_trigger(struct trigger *trigger, void *event);
 
 /**
diff --git a/src/box/iproto.cc b/src/box/iproto.cc
index 8f899fed8..34c8f469a 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -1505,7 +1505,7 @@ error:
 	tx_reply_error(msg);
 }
 
-static void
+static int
 tx_process_call_on_yield(struct trigger *trigger, void *event)
 {
 	(void)event;
@@ -1513,6 +1513,7 @@ tx_process_call_on_yield(struct trigger *trigger, void *event)
 	TRASH(&msg->call);
 	tx_discard_input(msg);
 	trigger_clear(trigger);
+	return 0;
 }
 
 static void
diff --git a/src/box/lua/call.c b/src/box/lua/call.c
index 631003c84..2612c5c63 100644
--- a/src/box/lua/call.c
+++ b/src/box/lua/call.c
@@ -952,17 +952,18 @@ lbox_func_delete(struct lua_State *L, struct func *func)
 	lua_pop(L, 2); /* box, func */
 }
 
-static void
+static int
 lbox_func_new_or_delete(struct trigger *trigger, void *event)
 {
 	struct lua_State *L = (struct lua_State *) trigger->data;
 	struct func *func = (struct func *)event;
 	if (!func->def->exports.lua)
-		return;
+		return 0;
 	if (func_by_id(func->def->fid) != NULL)
 		lbox_func_new(L, func);
 	else
 		lbox_func_delete(L, func);
+	return 0;
 }
 
 static struct trigger on_alter_func_in_lua = {
diff --git a/src/box/lua/sequence.c b/src/box/lua/sequence.c
index bd9ec7589..bf0714c1a 100644
--- a/src/box/lua/sequence.c
+++ b/src/box/lua/sequence.c
@@ -157,7 +157,7 @@ lbox_sequence_delete(struct lua_State *L, struct sequence *seq)
 	lua_pop(L, 2); /* box, sequence */
 }
 
-static void
+static int
 lbox_sequence_new_or_delete(struct trigger *trigger, void *event)
 {
 	struct lua_State *L = trigger->data;
@@ -166,6 +166,7 @@ lbox_sequence_new_or_delete(struct trigger *trigger, void *event)
 		lbox_sequence_new(L, seq);
 	else
 		lbox_sequence_delete(L, seq);
+	return 0;
 }
 
 void
diff --git a/src/box/lua/space.cc b/src/box/lua/space.cc
index d0a7e7815..ea8294f95 100644
--- a/src/box/lua/space.cc
+++ b/src/box/lua/space.cc
@@ -500,7 +500,7 @@ box_lua_space_delete(struct lua_State *L, uint32_t id)
 	lua_pop(L, 2); /* box, space */
 }
 
-static void
+static int
 box_lua_space_new_or_delete(struct trigger *trigger, void *event)
 {
 	struct lua_State *L = (struct lua_State *) trigger->data;
@@ -511,6 +511,7 @@ box_lua_space_new_or_delete(struct trigger *trigger, void *event)
 	} else {
 		box_lua_space_delete(L, space->def->id);
 	}
+	return 0;
 }
 
 static struct trigger on_alter_space_in_lua = {
diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c
index 487cfdadd..601e98ce5 100644
--- a/src/box/memtx_space.c
+++ b/src/box/memtx_space.c
@@ -834,7 +834,7 @@ struct memtx_ddl_state {
 	int rc;
 };
 
-static void
+static int
 memtx_check_on_replace(struct trigger *trigger, void *event)
 {
 	struct txn *txn = event;
@@ -843,11 +843,11 @@ memtx_check_on_replace(struct trigger *trigger, void *event)
 
 	/* Nothing to check on DELETE. */
 	if (stmt->new_tuple == NULL)
-		return;
+		return 0;
 
 	/* We have already failed. */
 	if (state->rc != 0)
-		return;
+		return 0;
 
 	/*
 	 * Only check format for already processed part of the space,
@@ -856,11 +856,12 @@ memtx_check_on_replace(struct trigger *trigger, void *event)
 	 */
 	if (tuple_compare(state->cursor, HINT_NONE, stmt->new_tuple, HINT_NONE,
 			  state->cmp_def) < 0)
-		return;
+		return 0;
 
 	state->rc = tuple_validate(state->format, stmt->new_tuple);
 	if (state->rc != 0)
 		diag_move(diag_get(), &state->diag);
+	return 0;
 }
 
 static int
@@ -957,7 +958,7 @@ memtx_init_ephemeral_space(struct space *space)
 	memtx_space_add_primary_key(space);
 }
 
-static void
+static int
 memtx_build_on_replace(struct trigger *trigger, void *event)
 {
 	struct txn *txn = event;
@@ -972,13 +973,13 @@ memtx_build_on_replace(struct trigger *trigger, void *event)
 	 */
 	if (tuple_compare(state->cursor, HINT_NONE, cmp_tuple, HINT_NONE,
 			  state->cmp_def) < 0)
-		return;
+		return 0;
 
 	if (stmt->new_tuple != NULL &&
 	    tuple_validate(state->format, stmt->new_tuple) != 0) {
 		state->rc = -1;
 		diag_move(diag_get(), &state->diag);
-		return;
+		return 0;
 	}
 
 	struct tuple *delete = NULL;
@@ -991,7 +992,7 @@ memtx_build_on_replace(struct trigger *trigger, void *event)
 	if (state->rc != 0) {
 		diag_move(diag_get(), &state->diag);
 	}
-	return;
+	return 0;
 }
 
 static int
diff --git a/src/box/relay.cc b/src/box/relay.cc
index a19abf6a9..5ce7287a5 100644
--- a/src/box/relay.cc
+++ b/src/box/relay.cc
@@ -388,7 +388,7 @@ tx_gc_advance(struct cmsg *msg)
 	free(m);
 }
 
-static void
+static int
 relay_on_close_log_f(struct trigger *trigger, void * /* event */)
 {
 	static const struct cmsg_hop route[] = {
@@ -398,7 +398,7 @@ relay_on_close_log_f(struct trigger *trigger, void * /* event */)
 	struct relay_gc_msg *m = (struct relay_gc_msg *)malloc(sizeof(*m));
 	if (m == NULL) {
 		say_warn("failed to allocate relay gc message");
-		return;
+		return 0;
 	}
 	cmsg_init(&m->msg, route);
 	m->relay = relay;
@@ -409,6 +409,7 @@ relay_on_close_log_f(struct trigger *trigger, void * /* event */)
 	 * sent xlog.
 	 */
 	stailq_add_tail_entry(&relay->pending_gc, m, in_pending);
+	return 0;
 }
 
 /**
diff --git a/src/box/replication.cc b/src/box/replication.cc
index d691ce487..82bf496c8 100644
--- a/src/box/replication.cc
+++ b/src/box/replication.cc
@@ -147,7 +147,7 @@ replica_is_orphan(struct replica *replica)
 	       relay_get_state(replica->relay) != RELAY_FOLLOW;
 }
 
-static void
+static int
 replica_on_applier_state_f(struct trigger *trigger, void *event);
 
 static struct replica *
@@ -401,7 +401,7 @@ replica_on_applier_disconnect(struct replica *replica)
 		replicaset.applier.loading++;
 }
 
-static void
+static int
 replica_on_applier_state_f(struct trigger *trigger, void *event)
 {
 	(void)event;
@@ -415,10 +415,14 @@ replica_on_applier_state_f(struct trigger *trigger, void *event)
 		replicaset.is_joining = false;
 		break;
 	case APPLIER_CONNECTED:
-		if (tt_uuid_is_nil(&replica->uuid))
-			replica_on_applier_connect(replica);
-		else
-			replica_on_applier_reconnect(replica);
+		try {
+			if (tt_uuid_is_nil(&replica->uuid))
+				replica_on_applier_connect(replica);
+			else
+				replica_on_applier_reconnect(replica);
+		} catch (Exception *e) {
+			return -1;
+		}
 		break;
 	case APPLIER_LOADING:
 	case APPLIER_DISCONNECTED:
@@ -443,6 +447,7 @@ replica_on_applier_state_f(struct trigger *trigger, void *event)
 		break;
 	}
 	fiber_cond_signal(&replicaset.applier.cond);
+	return 0;
 }
 
 /**
@@ -575,7 +580,7 @@ struct applier_on_connect {
 	struct replicaset_connect_state *state;
 };
 
-static void
+static int
 applier_on_connect_f(struct trigger *trigger, void *event)
 {
 	struct applier_on_connect *on_connect = container_of(trigger,
@@ -592,10 +597,11 @@ applier_on_connect_f(struct trigger *trigger, void *event)
 		state->connected++;
 		break;
 	default:
-		return;
+		return 0;
 	}
 	fiber_cond_signal(&state->wakeup);
 	applier_pause(applier);
+	return 0;
 }
 
 void
diff --git a/src/box/session.cc b/src/box/session.cc
index 59bf226dd..d69b6572f 100644
--- a/src/box/session.cc
+++ b/src/box/session.cc
@@ -80,7 +80,7 @@ sid_max()
 	return sid_max;
 }
 
-static void
+static int
 session_on_stop(struct trigger *trigger, void * /* event */)
 {
 	/*
@@ -91,6 +91,7 @@ session_on_stop(struct trigger *trigger, void * /* event */)
 	trigger_clear(trigger);
 	/* Destroy the session */
 	session_destroy(fiber_get_session(fiber()));
+	return 0;
 }
 
 static int
diff --git a/src/box/txn.c b/src/box/txn.c
index 38b1b595f..963ec8eeb 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -40,10 +40,10 @@ double too_long_threshold;
 /* Txn cache. */
 static struct stailq txn_cache = {NULL, &txn_cache.first};
 
-static void
+static int
 txn_on_stop(struct trigger *trigger, void *event);
 
-static void
+static int
 txn_on_yield(struct trigger *trigger, void *event);
 
 static void
@@ -839,12 +839,13 @@ txn_savepoint_release(struct txn_savepoint *svp)
 	rlist_cut_before(&discard, &txn->savepoints, rlist_next(&svp->link));
 }
 
-static void
+static int
 txn_on_stop(struct trigger *trigger, void *event)
 {
 	(void) trigger;
 	(void) event;
 	txn_rollback(in_txn());                 /* doesn't yield or fail */
+	return 0;
 }
 
 /**
@@ -864,7 +865,7 @@ txn_on_stop(struct trigger *trigger, void *event)
  * So much hassle to be user-friendly until we have a true
  * interactive transaction support in memtx.
  */
-static void
+static int
 txn_on_yield(struct trigger *trigger, void *event)
 {
 	(void) trigger;
@@ -874,4 +875,5 @@ txn_on_yield(struct trigger *trigger, void *event)
 	assert(!txn_has_flag(txn, TXN_CAN_YIELD));
 	txn_rollback_to_svp(txn, NULL);
 	txn_set_flag(txn, TXN_IS_ABORTED_BY_YIELD);
+	return 0;
 }
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index 7455c2c86..fa5e8a34d 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -1004,7 +1004,7 @@ struct vy_check_format_ctx {
  * This is an on_replace trigger callback that checks inserted
  * tuples against a new format.
  */
-static void
+static int
 vy_check_format_on_replace(struct trigger *trigger, void *event)
 {
 	struct txn *txn = event;
@@ -1012,15 +1012,16 @@ vy_check_format_on_replace(struct trigger *trigger, void *event)
 	struct vy_check_format_ctx *ctx = trigger->data;
 
 	if (stmt->new_tuple == NULL)
-		return; /* DELETE, nothing to do */
+		return 0; /* DELETE, nothing to do */
 
 	if (ctx->is_failed)
-		return; /* already failed, nothing to do */
+		return 0; /* already failed, nothing to do */
 
 	if (tuple_validate(ctx->format, stmt->new_tuple) != 0) {
 		ctx->is_failed = true;
 		diag_move(diag_get(), &ctx->diag);
 	}
+	return 0;
 }
 
 static int
@@ -3605,13 +3606,14 @@ fail:
 
 /* {{{ Cursor */
 
-static void
+static int
 vinyl_iterator_on_tx_destroy(struct trigger *trigger, void *event)
 {
 	(void)event;
 	struct vinyl_iterator *it = container_of(trigger,
 			struct vinyl_iterator, on_tx_destroy);
 	it->tx = NULL;
+	return 0;
 }
 
 static int
@@ -3916,7 +3918,7 @@ struct vy_build_ctx {
  * This is an on_replace trigger callback that forwards DML requests
  * to the index that is currently being built.
  */
-static void
+static int
 vy_build_on_replace(struct trigger *trigger, void *event)
 {
 	struct txn *txn = event;
@@ -3927,7 +3929,7 @@ vy_build_on_replace(struct trigger *trigger, void *event)
 	struct vy_lsm *lsm = ctx->lsm;
 
 	if (ctx->is_failed)
-		return; /* already failed, nothing to do */
+		return 0; /* already failed, nothing to do */
 
 	/* Check new tuples for conformity to the new format. */
 	if (stmt->new_tuple != NULL &&
@@ -3964,7 +3966,7 @@ vy_build_on_replace(struct trigger *trigger, void *event)
 		if (rc != 0)
 			goto err;
 	}
-	return;
+	return 0;
 err:
 	/*
 	 * No need to abort the DDL request if this transaction
@@ -3974,9 +3976,10 @@ err:
 	 * context isn't valid and so we must not modify it.
 	 */
 	if (tx->state == VINYL_TX_ABORT)
-		return;
+		return 0;
 	ctx->is_failed = true;
 	diag_move(diag_get(), &ctx->diag);
+	return 0;
 }
 
 /**
@@ -4372,7 +4375,7 @@ out:
 
 /* {{{ Deferred DELETE handling */
 
-static void
+static int
 vy_deferred_delete_on_commit(struct trigger *trigger, void *event)
 {
 	struct txn *txn = event;
@@ -4385,15 +4388,17 @@ vy_deferred_delete_on_commit(struct trigger *trigger, void *event)
 	mem->dump_lsn = txn->signature;
 	/* Unpin the mem pinned in vy_deferred_delete_on_replace(). */
 	vy_mem_unpin(mem);
+	return 0;
 }
 
-static void
+static int
 vy_deferred_delete_on_rollback(struct trigger *trigger, void *event)
 {
 	(void)event;
 	struct vy_mem *mem = trigger->data;
 	/* Unpin the mem pinned in vy_deferred_delete_on_replace(). */
 	vy_mem_unpin(mem);
+	return 0;
 }
 
 /**
@@ -4420,7 +4425,7 @@ vy_deferred_delete_on_rollback(struct trigger *trigger, void *event)
  * one of the trees got dumped while the other didn't, we would
  * mistakenly skip both statements on recovery.
  */
-static void
+static int
 vy_deferred_delete_on_replace(struct trigger *trigger, void *event)
 {
 	(void)trigger;
@@ -4430,7 +4435,7 @@ vy_deferred_delete_on_replace(struct trigger *trigger, void *event)
 	bool is_first_statement = txn_is_first_statement(txn);
 
 	if (stmt->new_tuple == NULL)
-		return;
+		return 0;
 	/*
 	 * Extract space id, LSN of the deferred DELETE statement,
 	 * and the deleted tuple from the system space row.
@@ -4439,27 +4444,27 @@ vy_deferred_delete_on_replace(struct trigger *trigger, void *event)
 	tuple_rewind(&it, stmt->new_tuple);
 	uint32_t space_id;
 	if (tuple_next_u32(&it, &space_id) != 0)
-		diag_raise();
+		return -1;
 	uint64_t lsn;
 	if (tuple_next_u64(&it, &lsn) != 0)
-		diag_raise();
+		return -1;
 	const char *delete_data = tuple_next_with_type(&it, MP_ARRAY);
 	if (delete_data == NULL)
-		diag_raise();
+		return -1;
 	const char *delete_data_end = delete_data;
 	mp_next(&delete_data_end);
 
 	/* Look up the space. */
 	struct space *space = space_cache_find(space_id);
 	if (space == NULL)
-		diag_raise();
+		return -1;
 	/*
 	 * All secondary indexes could have been dropped, in
 	 * which case we don't need to generate deferred DELETE
 	 * statements anymore.
 	 */
 	if (space->index_count <= 1)
-		return;
+		return 0;
 	/*
 	 * Wait for memory quota if necessary before starting to
 	 * process the batch (we can't yield between statements).
@@ -4473,7 +4478,7 @@ vy_deferred_delete_on_replace(struct trigger *trigger, void *event)
 	struct tuple *delete = vy_stmt_new_delete(pk->mem_format, delete_data,
 						  delete_data_end);
 	if (delete == NULL)
-		diag_raise();
+		return -1;
 	/*
 	 * A deferred DELETE may be generated after new statements
 	 * were committed for the deleted key. So we must use the
@@ -4565,7 +4570,8 @@ vy_deferred_delete_on_replace(struct trigger *trigger, void *event)
 
 	tuple_unref(delete);
 	if (rc != 0)
-		diag_raise();
+		return -1;
+	return 0;
 }
 
 static struct trigger on_replace_vinyl_deferred_delete = {
diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c
index ee361c31f..86bed8013 100644
--- a/src/box/vy_scheduler.c
+++ b/src/box/vy_scheduler.c
@@ -510,7 +510,7 @@ vy_scheduler_reset_stat(struct vy_scheduler *scheduler)
 	stat->compaction_output = 0;
 }
 
-static void
+static int
 vy_scheduler_on_delete_lsm(struct trigger *trigger, void *event)
 {
 	struct vy_lsm *lsm = event;
@@ -521,6 +521,7 @@ vy_scheduler_on_delete_lsm(struct trigger *trigger, void *event)
 	vy_compaction_heap_delete(&scheduler->compaction_heap, lsm);
 	trigger_clear(trigger);
 	free(trigger);
+	return 0;
 }
 
 int
diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c
index ce90f930c..710940838 100644
--- a/src/lib/core/fiber.c
+++ b/src/lib/core/fiber.c
@@ -1292,12 +1292,13 @@ cord_cojoin(struct cord *cord)
 	return cord_join(cord);
 }
 
-void
+int
 break_ev_loop_f(struct trigger *trigger, void *event)
 {
 	(void) trigger;
 	(void) event;
 	ev_break(loop(), EVBREAK_ALL);
+    	return 0;
 }
 
 struct costart_ctx
diff --git a/src/lib/core/trigger.cc b/src/lib/core/trigger.cc
index 4a43151e1..9f8a477c1 100644
--- a/src/lib/core/trigger.cc
+++ b/src/lib/core/trigger.cc
@@ -36,11 +36,12 @@ int
 trigger_run(struct rlist *list, void *event)
 {
 	try {
-		struct trigger *trigger, *tmp;
-		rlist_foreach_entry_safe(trigger, list, link, tmp)
-			trigger->run(trigger, event);
+	struct trigger *trigger, *tmp;
+	rlist_foreach_entry_safe(trigger, list, link, tmp)
+		if (trigger->run(trigger, event) != 0)
+			return -1;
 	} catch (Exception *e) {
-		return -1;
+			return -1;
 	}
 	return 0;
 }
@@ -49,11 +50,12 @@ int
 trigger_run_reverse(struct rlist *list, void *event)
 {
 	try {
-		struct trigger *trigger, *tmp;
-		rlist_foreach_entry_safe_reverse(trigger, list, link, tmp)
-			trigger->run(trigger, event);
+	struct trigger *trigger, *tmp;
+	rlist_foreach_entry_safe_reverse(trigger, list, link, tmp)
+		if (trigger->run(trigger, event) != 0)
+			return -1;
 	} catch (Exception *e) {
-		return -1;
+			return -1;
 	}
 	return 0;
 }
diff --git a/src/lib/core/trigger.h b/src/lib/core/trigger.h
index 76fa6345d..7b500dd92 100644
--- a/src/lib/core/trigger.h
+++ b/src/lib/core/trigger.h
@@ -40,7 +40,7 @@ extern "C" {
  * on an event.
  */
 struct trigger;
-typedef void (*trigger_f)(struct trigger *trigger, void *event);
+typedef int (*trigger_f)(struct trigger *trigger, void *event);
 typedef void (*trigger_f0)(struct trigger *trigger);
 
 struct trigger
diff --git a/src/lua/trigger.c b/src/lua/trigger.c
index 4803e85c5..83718ddc3 100644
--- a/src/lua/trigger.c
+++ b/src/lua/trigger.c
@@ -62,7 +62,7 @@ lbox_trigger_destroy(struct trigger *ptr)
 	free(ptr);
 }
 
-static void
+static int
 lbox_trigger_run(struct trigger *ptr, void *event)
 {
 	struct lbox_trigger *trigger = (struct lbox_trigger *) ptr;
@@ -97,14 +97,14 @@ lbox_trigger_run(struct trigger *ptr, void *event)
 	}
 	if (luaT_call(L, nargs, LUA_MULTRET)) {
 		luaL_unref(tarantool_L, LUA_REGISTRYINDEX, coro_ref);
-		diag_raise();
+	    	return -1;
 	}
 	int nret = lua_gettop(L) - top;
 	if (trigger->pop_event != NULL &&
 	    trigger->pop_event(L, nret, event) != 0) {
 		lua_settop(L, top);
 		luaL_unref(tarantool_L, LUA_REGISTRYINDEX, coro_ref);
-		diag_raise();
+	    	return -1;
 	}
 	/*
 	 * Clear the stack after pop_event saves all
@@ -112,6 +112,7 @@ lbox_trigger_run(struct trigger *ptr, void *event)
 	 */
 	lua_settop(L, top);
 	luaL_unref(tarantool_L, LUA_REGISTRYINDEX, coro_ref);
+    	return 0;
 }
 
 static struct lbox_trigger *
diff --git a/src/main.cc b/src/main.cc
index b16cfa5fe..da095ebf7 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -683,10 +683,11 @@ print_help(const char *program)
 	puts("to see online documentation, submit bugs or contribute a patch.");
 }
 
-static void
+static int
 break_loop(struct trigger *, void *)
 {
 	ev_break(loop(), EVBREAK_ALL);
+	return 0;
 }
 
 int
diff --git a/test/unit/cbus.c b/test/unit/cbus.c
index be930ab8f..ecf5fce72 100644
--- a/test/unit/cbus.c
+++ b/test/unit/cbus.c
@@ -43,13 +43,14 @@ do_nothing(struct cmsg *m)
 }
 
 /** Callback called on each flush to the main thread. */
-static void
+static int
 flush_cb(struct trigger *t, void *e)
 {
 	(void) t;
 	(void) e;
 	++flushed_cnt;
 	printf("flush event, counter = %d\n", flushed_cnt);
+	return 0;
 }
 
 /** Callback to finish the test. It breaks the main event loop. */
diff --git a/test/unit/swim.c b/test/unit/swim.c
index 1371e7d26..bb12baf8d 100644
--- a/test/unit/swim.c
+++ b/test/unit/swim.c
@@ -827,7 +827,7 @@ struct trigger_ctx {
 	struct swim_on_member_event_ctx ctx;
 };
 
-static void
+static int
 swim_on_member_event_save(struct trigger *t, void *event)
 {
 	struct trigger_ctx *c = (struct trigger_ctx *) t->data;
@@ -836,9 +836,10 @@ swim_on_member_event_save(struct trigger *t, void *event)
 		swim_member_unref(c->ctx.member);
 	c->ctx = *((struct swim_on_member_event_ctx *) event);
 	swim_member_ref(c->ctx.member);
+	return 0;
 }
 
-static void
+static int
 swim_on_member_event_yield(struct trigger *t, void *event)
 {
 	struct trigger_ctx *c = (struct trigger_ctx *) t->data;
@@ -846,6 +847,7 @@ swim_on_member_event_yield(struct trigger *t, void *event)
 	c->f = fiber();
 	while (c->need_sleep)
 		fiber_yield();
+	return 0;
 }
 
 static void
diff --git a/test/unit/swim_test_utils.c b/test/unit/swim_test_utils.c
index 7da82d93c..9dbd28a9f 100644
--- a/test/unit/swim_test_utils.c
+++ b/test/unit/swim_test_utils.c
@@ -176,7 +176,7 @@ swim_cluster_id_to_uri(char *buffer, int id)
  * A trigger to check correctness of event context, and ability
  * to yield.
  */
-void
+int
 swim_test_event_cb(struct trigger *trigger, void *event)
 {
 	(void) trigger;
@@ -186,6 +186,7 @@ swim_test_event_cb(struct trigger *trigger, void *event)
 	assert((ctx->events & SWIM_EV_NEW) == 0 ||
 	       (ctx->events & SWIM_EV_DROP) == 0);
 	fiber_sleep(0);
+	return 0;
 }
 
 /** Create a SWIM cluster node @a n with a 0-based @a id. */
-- 
2.17.1

  reply	other threads:[~2019-09-11 13:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11 13:05 [tarantool-patches] [PATCH v3 0/5] refactoring: remove exceptions from triggers Ilya Kosarev
2019-09-11 13:05 ` Ilya Kosarev [this message]
2019-09-11 13:05 ` [tarantool-patches] [PATCH v3 2/5] refactoring: remove exceptions from used in alter.cc outer functions Ilya Kosarev
2019-09-11 13:05 ` [tarantool-patches] [PATCH v3 3/5] refactoring: replace exceptions in most alter.cc functions Ilya Kosarev
2019-09-11 13:05 ` [tarantool-patches] [PATCH v3 4/5] refactoring: remove obvious exceptions in alter.cc Ilya Kosarev
2019-09-11 13:05 ` [tarantool-patches] [PATCH v3 5/5] refactoring: replace remaining exceptions in alter.cc & update comments Ilya Kosarev

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=4b38ca3cc5774e669aa74b6fae9a25a8b09a4365.1568206816.git.i.kosarev@tarantool.org \
    --to=i.kosarev@tarantool.org \
    --cc=georgy@tarantool.org \
    --cc=i.kosarev@corp.mail.ru \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v3 1/5] refactoring: remove exceptions from triggers except alter.cc' \
    /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