Skip to content

Commit 053d358

Browse files
committed
broker: rate limit broker online messages
Problem: on a large cluster logging the online set every time a new host joins generates too much log traffic in the systemd journal. Rate limit those log messages to one per 5s. Fixes #4556
1 parent 62c12ac commit 053d358

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/broker/state_machine.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,9 @@ static void broker_online_cb (flux_future_t *f, void *arg)
712712
struct state_machine *s = arg;
713713
const char *members;
714714
struct idset *ids;
715+
static double last_update = 0;
716+
double now = flux_reactor_now (flux_get_reactor (s->ctx->h));
717+
bool quorum_reached = false;
715718

716719
if (flux_rpc_get_unpack (f, "{s:s}", "members", &members) < 0
717720
|| !(ids = idset_decode (members))) {
@@ -720,15 +723,21 @@ static void broker_online_cb (flux_future_t *f, void *arg)
720723
return;
721724
}
722725

723-
if (strlen (members) > 0) {
726+
idset_destroy (s->quorum.have);
727+
s->quorum.have = ids;
728+
if (is_subset_of (s->quorum.want, s->quorum.have)) {
729+
quorum_reached = true;
730+
}
731+
732+
if (strlen (members) > 0
733+
&& (quorum_reached || now - last_update > 5)) {
724734
char *hosts = flux_hostmap_lookup (s->ctx->h, members, NULL);
725735
flux_log (s->ctx->h, LOG_INFO, "online: %s (ranks %s)", hosts, members);
726736
free (hosts);
737+
last_update = now;
727738
}
728739

729-
idset_destroy (s->quorum.have);
730-
s->quorum.have = ids;
731-
if (is_subset_of (s->quorum.want, s->quorum.have)) {
740+
if (quorum_reached) {
732741
if (s->state != STATE_RUN) {
733742
state_machine_post (s, "quorum-full");
734743
if (s->quorum.warned) {

0 commit comments

Comments
 (0)