[Tarantool-patches] [PATCH v2 06/10] box: introduce stacked diagnostic area

Konstantin Osipov kostja.osipov at gmail.com
Thu Mar 26 19:54:13 MSK 2020


* Nikita Pettik <korablev at tarantool.org> [20/03/25 09:32]:
> +	/*
> +	 * Make sure that adding error won't result in cycles.
> +	 * Don't bother with sophisticated cycle-detection
> +	 * algorithms, simple iteration is OK since as a rule
> +	 * list contains a dozen errors at maximum.
> +	 */
> +	struct error *tmp = prev;
> +	while (tmp != NULL) {
> +		if (tmp == e)
> +			return -1;
> +		tmp = tmp->cause;
> +	}

If you have to do it, better use rlist, rlist_del(e) rlist_add(e),
this will make sure there are no cycles and the cost is constant.

> +	if (prev != NULL) {
> +		error_unlink_effect(prev);
> +		prev->effect = e;
> +		error_ref(prev);
> +	}

cause and effect can be just wrappers around rlist_prev/next, if
you have to. But error stack is not always cause and effect:
imagine an SQL update which runs a bunch of triggers which all set
add some errors to the diag, which one of these triggers errors is
the cause of update error?.


-- 
Konstantin Osipov, Moscow, Russia


More information about the Tarantool-patches mailing list