From: Serge Petrenko <sergepetrenko@tarantool.org>
To: v.shpilevoy@tarantool.org, cyrillos@gmail.com
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH 2/4] relay: rename is_raft_enabled message to relay_is_running
Date: Thu, 10 Dec 2020 23:55:12 +0300 [thread overview]
Message-ID: <3600a9d1e06d6c1c8cda41dda88cd0dd088ca3e2.1607633488.git.sergepetrenko@tarantool.org> (raw)
In-Reply-To: <cover.1607633488.git.sergepetrenko@tarantool.org>
Relay sends a raft enabler/disabler message on start and stop. This
message would also be useful to perform some additional work related to relay
initialization/deinitialization done in the tx thread.
For example, the message will be used to notify tx thread that there's no
point in wating until a relay replicates a specific row, since the relay
is exiting. This is the case in #5435.
So rename the message and all the connected functions to represent its
enriched functionality.
Prerequisite #5435
---
src/box/relay.cc | 47 +++++++++++++++++++++++------------------------
1 file changed, 23 insertions(+), 24 deletions(-)
diff --git a/src/box/relay.cc b/src/box/relay.cc
index e16ac5a6b..f342a79dd 100644
--- a/src/box/relay.cc
+++ b/src/box/relay.cc
@@ -579,8 +579,8 @@ relay_send_heartbeat(struct relay *relay)
}
}
-/** A message to set Raft enabled flag in TX thread from a relay thread. */
-struct relay_is_raft_enabled_msg {
+/** A message to notify the TX thread that relay is operational. */
+struct relay_is_running_msg {
/** Base cbus message. */
struct cmsg base;
/**
@@ -590,44 +590,45 @@ struct relay_is_raft_enabled_msg {
struct cmsg_hop route[2];
/** Relay pointer to set the flag in. */
struct relay *relay;
- /** New flag value. */
- bool value;
+ /** Relay running status. */
+ bool is_running;
/** Flag to wait for the flag being set, in a relay thread. */
bool is_finished;
};
-/** TX thread part of the Raft flag setting, first hop. */
+/** TX thread part of the relay is running notification, first hop. */
static void
-tx_set_is_raft_enabled(struct cmsg *base)
+tx_notify_is_relay_running(struct cmsg *base)
{
- struct relay_is_raft_enabled_msg *msg =
- (struct relay_is_raft_enabled_msg *)base;
- msg->relay->tx.is_raft_enabled = msg->value;
+ struct relay_is_running_msg *msg = (struct relay_is_running_msg *)base;
+ /* Never subscribe anonymous replicas to raft updates. */
+ if (!msg->relay->replica->anon)
+ msg->relay->tx.is_raft_enabled = msg->is_running;
}
-/** Relay thread part of the Raft flag setting, second hop. */
+/** Relay thread part of the relay is running notification, second hop. */
static void
-relay_set_is_raft_enabled(struct cmsg *base)
+relay_notify_is_relay_running(struct cmsg *base)
{
- struct relay_is_raft_enabled_msg *msg =
- (struct relay_is_raft_enabled_msg *)base;
+ struct relay_is_running_msg *msg = (struct relay_is_running_msg *)base;
msg->is_finished = true;
}
/**
- * Set relay Raft enabled flag from a relay thread to be accessed by the TX
+ * Notify the TX thread that the relay is operational.
+ * For now this will only set relay Raft enabled flag to be accessed by the TX
* thread.
*/
static void
-relay_send_is_raft_enabled(struct relay *relay,
- struct relay_is_raft_enabled_msg *msg, bool value)
+relay_send_is_running(struct relay *relay, struct relay_is_running_msg *msg,
+ bool is_running)
{
- msg->route[0].f = tx_set_is_raft_enabled;
+ msg->route[0].f = tx_notify_is_relay_running;
msg->route[0].pipe = &relay->relay_pipe;
- msg->route[1].f = relay_set_is_raft_enabled;
+ msg->route[1].f = relay_notify_is_relay_running;
msg->route[1].pipe = NULL;
msg->relay = relay;
- msg->value = value;
+ msg->is_running = is_running;
msg->is_finished = false;
cmsg_init(&msg->base, msg->route);
cpipe_push(&relay->tx_pipe, &msg->base);
@@ -667,9 +668,8 @@ relay_subscribe_f(va_list ap)
cbus_pair("tx", relay->endpoint.name, &relay->tx_pipe,
&relay->relay_pipe, NULL, NULL, cbus_process);
- struct relay_is_raft_enabled_msg raft_enabler;
- if (!relay->replica->anon)
- relay_send_is_raft_enabled(relay, &raft_enabler, true);
+ struct relay_is_running_msg relay_is_running_msg;
+ relay_send_is_running(relay, &relay_is_running_msg, true);
/*
* Setup garbage collection trigger.
@@ -750,8 +750,7 @@ relay_subscribe_f(va_list ap)
cpipe_push(&relay->tx_pipe, &relay->status_msg.msg);
}
- if (!relay->replica->anon)
- relay_send_is_raft_enabled(relay, &raft_enabler, false);
+ relay_send_is_running(relay, &relay_is_running_msg, false);
/*
* Clear garbage collector trigger and WAL watcher.
--
2.24.3 (Apple Git-128)
next prev parent reply other threads:[~2020-12-10 20:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-10 20:55 [Tarantool-patches] [PATCH 0/4] make clear_synchro_queue commit everything Serge Petrenko
2020-12-10 20:55 ` [Tarantool-patches] [PATCH 1/4] box: add a single execution guard to clear_synchro_queue Serge Petrenko
2020-12-17 21:43 ` Vladislav Shpilevoy
2020-12-21 10:18 ` Serge Petrenko
2020-12-21 17:11 ` Vladislav Shpilevoy
2020-12-23 12:01 ` Serge Petrenko
2020-12-10 20:55 ` Serge Petrenko [this message]
2020-12-17 21:43 ` [Tarantool-patches] [PATCH 2/4] relay: rename is_raft_enabled message to relay_is_running Vladislav Shpilevoy
2020-12-23 12:01 ` Serge Petrenko
2020-12-10 20:55 ` [Tarantool-patches] [PATCH 3/4] relay: introduce relay_lsn_watcher Serge Petrenko
2020-12-17 21:43 ` Vladislav Shpilevoy
[not found] ` <4b7f4fc1-6d48-4332-c432-1eeb0b28c016@tarantool.org>
2020-12-23 12:03 ` Serge Petrenko
2020-12-10 20:55 ` [Tarantool-patches] [PATCH 4/4] box: rework clear_synchro_queue to commit everything Serge Petrenko
2020-12-17 21:43 ` Vladislav Shpilevoy
2020-12-23 12:04 ` Serge Petrenko
2020-12-11 7:15 ` [Tarantool-patches] [PATCH 0/4] make clear_synchro_queue " Serge Petrenko
2020-12-11 9:19 ` Serge Petrenko
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=3600a9d1e06d6c1c8cda41dda88cd0dd088ca3e2.1607633488.git.sergepetrenko@tarantool.org \
--to=sergepetrenko@tarantool.org \
--cc=cyrillos@gmail.com \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 2/4] relay: rename is_raft_enabled message to relay_is_running' \
/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