Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Sergey Kaplun <skaplun@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org,
	Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: Re: [Tarantool-patches] [DRAFT v1] replication: track information about replica
Date: Thu, 2 Jul 2020 18:53:47 +0300	[thread overview]
Message-ID: <20200702155347.GJ2256@grain> (raw)
In-Reply-To: <20200629203134.30177-1-skaplun@tarantool.org>

On Mon, Jun 29, 2020 at 11:31:34PM +0300, Sergey Kaplun wrote:
...
>  
> +static int
> +relay_on_state_f(struct trigger *trigger, void *event)
> +{

Sergey, I'll review the patch with more attention tomorrow, still
here are some notes which I can point early.

 - please don't name the trigger function with _f postfix, we usually
   do this for cord thread runners (I know here are a few exceptions
   but they are simply misnamed)

> +	struct relay *relay = (struct relay *)event;
> +	(void)trigger;

You can easily exit early

	if (relay_get_state(relay) == RELAY_OFF)
		return 0;

shifting the rest of the code left. Still up to you I do not insist.

> +	if (relay_get_state(relay) != RELAY_OFF) {
> +		struct replica *replica = relay_replica(relay);
> +		const struct tt_uuid *uuid = &replica->uuid;
> +		assert(replica_by_uuid(uuid) != NULL);
> +		assert(replica->id != REPLICA_ID_NIL);
> +		if (boxk(IPROTO_UPDATE, BOX_CLUSTER_ID, "[%u]["
> +		         "[%s%u%lf]" /* last row time */
> +		         "[%s%u%s]" /* vclock */
> +		         "[%s%u%s]" /* relay state */
> +		         "]",
> +		         (unsigned) replica->id,
> +		         "=", 3, relay_last_row_time(relay),
> +		         "=", 4, vclock_to_string(relay_vclock(relay)),
> +		         "=", 5, relay_get_state_str(relay)
> +		        ) != 0) {
> +			diag_raise();
> +		}

Do we really need to call diag_raise() here?

> +		int rc;
> +		switch (relay_get_state(relay)) {
...
> +		}
> +		if (rc != 0)
> +			diag_raise();

And here. IIRC usually triggers simply return -1 on error.
The left of the patch is trimmed for now.

  reply	other threads:[~2020-07-02 15:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29 20:31 Sergey Kaplun
2020-07-02 15:53 ` Cyrill Gorcunov [this message]
2020-07-02 19:40   ` Sergey Kaplun

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=20200702155347.GJ2256@grain \
    --to=gorcunov@gmail.com \
    --cc=skaplun@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [DRAFT v1] replication: track information about replica' \
    /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